Agent Architecture
Mirobody provides three agent types, each optimized for a different cost/quality/latency point:DeepAgent
Complex workflowsSingle-model tool orchestration. Multi-step planning, file ops, subagents, persistent memory. The default for tool-assisted conversations.
MixAgent
Cost/quality balanceTwo-phase model fusion: a capable model orchestrates tool calls, a cheaper model writes the final reply with the collected context.
BaseAgent
Simple Q&ADirect LLM conversation without tools. Lowest latency. Good for trivial questions and benchmarking.
Agent Comparison
| Feature | DeepAgent | MixAgent | BaseAgent |
|---|---|---|---|
| Architecture | Single-model tool loop | Orchestrator + Responder (two-phase) | Direct LLM, no tools |
| Planning | ✅ Built-in todos | ✅ (orchestrator phase) | ❌ |
| File System | ✅ Full support | ✅ (orchestrator phase) | ❌ |
| Subagents | ✅ Task isolation | ✅ (orchestrator phase) | ❌ |
| MCP Tools | ✅ Full integration | ✅ (orchestrator phase) | ❌ |
| MCP Resources | ❌ | ❌ | ✅ Native |
| MCP Prompt Templates | ❌ | ❌ | ✅ Native |
| Memory | ✅ PostgreSQL | ✅ PostgreSQL | ❌ |
| Streaming | ✅ | ✅ (responder phase) | ✅ |
| Model Support | Multi-provider | Two providers (one per phase) | Gemini 2.5/3.0, MiroThinker |
| Cost Profile | One expensive model | Expensive orchestrator + cheap responder | One cheap model |
| Best For | Complex workflows, file ops | Long contexts where reply phase doesn’t need top-tier reasoning | Simple/lightweight tasks |
| Setup Complexity | Medium | Medium | Low |
DeepAgent (Recommended for Complex Tasks)
Features
- ✅ Multi-step Planning: Built-in task decomposition with TODO system
- ✅ File Operations: Read, write, edit files with glob and grep support
- ✅ Subagents: Spawn subagents for context isolation
- ✅ Long-term Memory: PostgreSQL-backed persistent memory
- ✅ Full MCP Tools: Complete integration with MCP tool ecosystem
Supported Providers
DeepAgent supports multiple LLM providers via LangChain:- Gemini 3.0 (via Google GenAI SDK)
- GPT-5 (via OpenAI API or OpenRouter)
- Claude Sonnet (via OpenRouter)
- DeepSeek v3.2 (via OpenRouter)
Configuration
config.localdb.yaml
Use Cases
- Complex health data analysis workflows
- Multi-step research and reporting
- File processing and management
- Tasks requiring persistent context
- Projects needing task decomposition
Usage Example
MixAgent (Two-Phase Cost/Quality Fusion)
MixAgent splits a single response into two model calls:- Orchestrator phase — a capable model (e.g. Claude Sonnet 4.5) handles the tool-calling loop. It plans, searches data, reads files, and stops when it has enough context.
- Responder phase — a cheaper model (e.g. Gemini 2.5 Flash) consumes the orchestrator’s collected context and writes the final user-facing reply.
When to choose MixAgent
- Long, tool-heavy conversations where the final summary doesn’t need top-tier reasoning (cost saver vs. DeepAgent).
- You want consistent voice/tone from a single model for the final reply while letting a different model handle tool dispatch.
- You’re billing by token and the responder’s context will be large.
When NOT to choose MixAgent
- Short Q&A — the two-pass overhead isn’t worth it; use DeepAgent or BaseAgent.
- The final reply quality is the bottleneck — promote it to DeepAgent with one strong model.
Configuration
The two phases are configured via theorchestrator / responder keys under PROVIDERS_MIX. See Agent Providers in Configuration for the full YAML.
ALLOWED_TOOLS_MIX / DISALLOWED_TOOLS_MIX (only the orchestrator phase touches tools).
BaseAgent (Best for Simple Tasks)
Features
- ✅ Native MCP: Direct MCP server support
- ✅ Streaming: Fast streaming responses
- ✅ Direct Tool Config: Tools configured directly to LLM
- ✅ Lightweight: Minimal overhead, fast execution
- ❌ No file operations
- ❌ No subagents
Supported Providers
- Gemini 2.5/3.0 (native Google GenAI)
- MiroThinker (custom model)
Configuration
config.localdb.yaml
Use Cases
- Simple health data queries
- Quick conversations
- Direct MCP tool usage
- Lightweight operations
- Native Gemini/MiroThinker features
Usage Example
Tools System
What are Tools?
Tools are Python functions that enable AI agents to interact with health data, perform actions, and access external services. Mirobody makes it easy to add custom functionality without complex configuration.Tool Structure
Built-in Tools
General Tools (mirobody/pub/tools/):
chart_service.py- 25+ chart types (line, bar, pie, sankey, etc.)
mirobody/pub/tools_health/):
genetic_service.py- Genetic data analysishealth_indicator_service.py- Health metrics trackinguser_service.py- User profile management
Tool Configuration
config.localdb.yaml
Creating Custom Tools
Create tool file
Create a new Python file in a configured tool directory:
mirobody/pub/tools/weather_service.py
Auto-discovery
Tools are automatically discovered when the server starts. No manual registration required!
Tool Best Practices
- Authentication: Use
user_infoparameter for user-specific operations - Error Handling: Return structured error responses
- Type Hints: Use proper type annotations for validation
- Documentation: Include clear docstrings with Args and Returns
- Async Operations: Prefer async functions for I/O operations
MCP Protocol Integration
Mirobody functions as an MCP (Model Context Protocol) server, enabling integration with:- Claude Desktop - Direct integration
- Cursor IDE - AI-powered coding assistant
- ChatGPT - Via custom GPT apps
- Custom MCP Clients - Any MCP-compatible client
MCP Endpoints
tools/list- List available toolstools/call- Execute tool functionsresources/list- List available resourcesresources/read- Read resource content
Database Schema for Health Data
Tools query standardized health data from these tables:th_series_data
Time-series health indicators:| Column | Type | Description |
|---|---|---|
id | integer | Primary key |
user_id | varchar | User identifier |
indicator | varchar | Indicator name |
value | text | Original value |
value_standardized | text | Standardized value |
start_time | timestamp | Start time |
end_time | timestamp | End time |
source | varchar | Data source |
source_table | varchar | Source table |
theta_ai.health_user_profile_by_system
User profile storage:| Column | Type | Description |
|---|---|---|
id | integer | Primary key |
user_id | varchar | User identifier |
version | integer | Version number |
name | varchar | Profile name |
last_execute_doc_id | integer | Last executed document ID |
common_part | varchar | Profile content (JSON) |
create_time | timestamp | Creation timestamp |
last_update_time | timestamp | Last update timestamp |
is_deleted | boolean | Deletion flag |
Next Steps
Built-in Tools
Explore the default health tools
Adding Custom Tools
Learn how to create your own tools
MCP Integration
Connect to Claude, Cursor, and ChatGPT
Adding MCPs
Add external MCP servers