System Architecture
MIU follows a layered, modular architecture with clear separation of concerns.Overview
Core Components
Framework Layer (miu-core)
- Agents
- Tools
- Providers
Location:
packages/miu_core/miu_core/agents/- BaseAgent: Abstract base class defining agent interface
- ReActAgent: Implements ReAct (Reasoning + Acting) pattern
Coding Agent Layer (miu-code)
TheCodingAgent specializes ReActAgent for code operations:
| Tool | Purpose | Parameters |
|---|---|---|
read | Read file contents | path: str |
write | Write new file | path: str, content: str |
edit | Modify existing file | path: str, old: str, new: str |
bash | Execute shell command | command: str |
glob | Find files by pattern | pattern: str |
grep | Search file contents | pattern: str, path: str |
TUI Application (miu-code)
Location:packages/miu_code/miu_code/tui/
Built with Textual framework:
- StatusBar: Shows mode, path, token usage
- Mode Management: NORMAL → PLAN → ASK cycling
- Session Control: New session, clear, quit
- Real-time Streaming: Text deltas, tool execution
Data Flow Patterns
Agent Execution Flow
Provider Abstraction
The provider interface allows swapping LLM backends without changing agent code:Multi-Agent Patterns
Three coordination patterns inpackages/miu_core/miu_core/patterns/:
Orchestrator
Coordinate agents with task dependencies using DAG
Pipeline
Sequential processing chain with stage transforms
Router
Route requests to specialist agents by keywords
Security Architecture
1
Input Validation
User input validated at entry point
2
Tool Security
Path validation, command escaping, result validation
3
Provider Layer
API key validation, request validation, rate limiting
4
External Services
Secure API communication
Extensibility
Adding a New Provider
Adding a New Tool
Async Architecture
- Event Loop: Single asyncio event loop
- Concurrency:
asyncio.gather()for parallel operations - I/O: All blocking operations are async
- Timeouts: All external calls have configurable timeouts