๐ The 5 Core Components
INTELECTO has exactly 5 distinct responsibilities. This division isn't arbitraryโeach component can be replaced, tested, and evolved independently of the others. That's the secret to keeping the system manageable.
๐งฉ The 5 Components
The brain. Receives messages, builds context, decides whether to use tools or respond directly, and orchestrates everything.
Access to LLMs. OpenRouter, Ollama, direct API. Any implementation of BaseProvider will work.
How the user communicates. Telegram, WhatsApp, Discord, CLI. Implement BaseChannel.
Context persistence. SQLite FTS5 with BM25 semantic search and automatic deduplication.
Real-world actions. Google Calendar, GitHub, browser, shell. Implement BaseTool.
๐จ Complete Message Flow
Each message follows a precise path. Understanding this flow is essential to knowing where to intervene when something fails and where to add new features.
๐ Flow Diagram
๐ก Practical Tip
To debug, add logs at every step of the flow. Python logging with different levels (DEBUG for Channel, INFO for Agent, WARNING for Safety) lets you pinpoint exactly where the problem occurs.
๐ The Agent Loop โ Max 5 Rounds
O loop.py is the heart of INTELECTO. It implements the ReAct pattern (Reason + Act): the AI thinks, decides to use a tool, receives the result, thinks again, and so onโuntil it reaches a final answer or hits the 5-round limit.
๐ The ReAct Cycle
LLM analyzes the message + context and decides what to do
If you decide to use a tool โ call tool.execute() with the parameters
Tool result enters context โ back to Reason
LLM generates a natural language response for the user
โ Why a 5-Round Limit?
Without a limit, a bug in the AI logic can cause an infinite loop โ costing hundreds of dollars in tokens. The limit of 5 is the circuit breaker that protects your billing. For complex tasks, adjust the limit carefully and always monitor it.
๐ The Workspace โ Configuration in Markdown
The directory workspace/ is where you define what your Jarvis is. Three Markdown files that are read and injected into every system prompt. Changing the AIโs behavior doesnโt require changing codeโjust editing these files.
๐งฌ SOUL.md
The AI's personality: name, tone of voice, values, communication style, ethical limitations. Defines who Jarvis is.
๐ AGENTS.md
Behavior rules: what to do, what never to do, how to prioritize tasks, when to ask for confirmation.
๐ง MEMORY.md
Bootstrap facts: information the AI needs to know from the first conversation without having to be taught.
๐ก Configuration as Code
Workspace files are "code" in the sense that they control system behavior. Version them with git, back them up, and treat changes to them with the same care as code changes.
๐งฉ Interface Contracts
The secret to INTELECTOโs extensibility is the interface contracts. Each component type has an abstract base class with required methods. If you follow the contract, your component works with everything else automatically.
๐ The 3 Main Contracts
The only required method. Any LLM that implements this works with the Agent.
async def send(user_id, msg) โ None
async def stop() โ None
3 methods. Telegram, WhatsApp, CLI โ all implement these 3.
description: str
parameters: dict # JSON Schema
async def execute(**kwargs) โ str
The description + parameters are sent to the LLM so it knows how to use the tool.
๐ Persistence in ~/.intelecto/
Everything INTELECTO persists is stored in ~/.intelecto/. Three critical files you need to know, back up, and never accidentally delete.
memory.db
SQLite database with FTS5 enabled. Stores facts (category: fact/conversation/solution), conversation history, and results of previous searches. BM25 for relevance ranking.
.secrets
API keys encrypted with Fernet. The encryption key is derived from the hardware UUID using PBKDF2. The file can only be decrypted on the same machine.
audit.log
Record of all actions: who requested them, what was executed, when, and with what result. Immutable by design โ each line is append-only.
โ Module 1.2 Summary
Next Module:
1.3 โ Environment Setup: from scratch to Jarvis running on Telegram