Async runtime glue connecting the sans-IO state machine to real I/O.
The [Runtime] struct orchestrates the full agent execution loop:
- Receives a user message
- Builds context (system prompt + history)
- Drives the sans-IO state machine via [
transition] - Executes actions: model calls, tool execution, memory compaction, approval
- Emits events through the hook stack
- Returns when the run finishes or is aborted
Architecture
User Message
│
▼
Runtime::run()
│
├─► build context (system prompt + history + RAG)
├─► transition(state, input) → (new_state, actions)
│ │
│ ├─► RequestModel → provider.stream() → events → ModelCompleted
│ ├─► ExecuteTool → tool_registry.execute() → ToolResultReceived
│ ├─► RequestToolApproval → approval_gate.request() → await decision
│ ├─► CompactMemory → memory compaction → MemoryCompactionCompleted
│ ├─► FinishRun → return RunOutput
│ └─► AbortRun → return error
│
└─► emit events → HookStack.dispatch() → EventActions