Agent Architecture
How the ArgentOS agent runtime connects the gateway, Claude API, tools, and memory.
Architecture Overview
The agent sits at the center of ArgentOS, bridging the gateway (which handles channels and the dashboard) with the Claude API and tool execution.
Channels ──> Gateway ──> Agent Runtime ──> Claude API
│ │
│ ├──> Tool Execution
│ ├──> Memory (MemU)
│ └──> Task System
│
└──> Dashboard (WebSocket)Components
Gateway
The gateway is the always-on WebSocket server that receives messages from all channels and the dashboard. It routes incoming messages to the agent runtime and broadcasts responses back. See Gateway for details.
Agent Runtime
The agent runtime (src/agents/) manages the interaction with the LLM:
- System prompt assembly -- Combines identity, soul, tool definitions, bootstrap memory, and injected context
- Message handling -- Receives normalized messages from the gateway
- API calls -- Sends requests to the Claude API (or other providers via the model router)
- Tool execution -- Processes tool use blocks returned by the model
- Response streaming -- Streams responses back to the gateway
Model Router
Before the API call, the model router scores the complexity of the request and routes it to the appropriate model tier. See Model Router.
Memory Integration
The agent has built-in memory_store and memory_recall tools that write to and read from MemU, the persistent SQLite memory database. Memory context is also injected into the system prompt at boot time. See Memory.
Tool System
Tools are defined as JSON schemas and registered with the agent runtime. When the model returns a tool_use block, the runtime executes the corresponding tool handler and returns the result. See Tools.
Message Flow (Detailed)
- User sends "What's on my task list?" on Telegram
- Telegram channel driver normalizes the message
- Gateway routes it to the agent's session
- Agent assembles the full prompt with system context
- Model router scores complexity -> routes to Haiku (simple query)
- Haiku returns a
tool_useblock fortasks_list - Agent runtime executes the tool, gets task data
- Tool result is sent back to the model
- Model generates a natural language response
- Response is streamed back through the gateway to Telegram
Configuration Reference
The agent runtime is configured via argent.json:
{
"agents": {
"defaults": {
"model": "claude-sonnet-4-20250514",
"maxTokens": 16384,
"temperature": 1,
"systemPrompt": {
"identity": true,
"soul": true,
"tools": true,
"bootstrap": true
}
}
}
}