The Router-Worker architecture separates intent classification, task planning, and agent execution into three distinct layers. This design enables fast-path optimization for simple queries while maintaining full autonomous capability for complex tasks.
Layer 1 — Intent Classification (IntentRouter)
The user's raw message is classified into an Intent Type and Plan Shape via a single LLM call that outputs exactly two tokens (e.g., EDIT TASKLIST).
Intent Types
| Intent | Plan Shape | Description |
|---|---|---|
Conversational | DirectAnswer | Greetings, small-talk, status questions |
CodeAnalysis | DirectAnswer | Read-only exploration, search, explanation |
CodeEdit | TaskList | Write operations, fixes, refactoring |
ShellTask | TaskList | Build, test, compile commands |
KnowledgeQuery | DirectAnswer | Architecture, patterns, "what does X do" |
FileStatsCount | DirectAnswer | Line counts, sizes, existence checks |
Unknown | TaskList | Ambiguous, fall back to full agent loop |
Plan Shapes
DirectAnswer- Single LLM response, no tools neededTaskList- Structured plan with executable steps
Layer 2 — Task Planning (TaskPlanner)
For TaskList intents, the planner compiles a concrete TaskPlan with steps that support output chaining via $stepN references.
TaskPlan Structure
{
"steps": [
{
"id": "step1",
"agent": "code_editor",
"action": "read_file",
"parameters": { "path": "Program.cs" },
"description": "Read the main entry point"
},
{
"id": "step2",
"agent": "code_editor",
"action": "apply_diff",
"parameters": { "path": "Program.cs", "diff": "Listing: C:\Users\x11\Desktop\newsite\GravityLandingPage\Views\Docs (top-level only)
Found 12 items:
- [FILE] Views\Docs\Architecture.cshtml
- [FILE] Views\Docs\Article.cshtml
- [FILE] Views\Docs\Article.cshtml.bak.639273610948482039
- [FILE] Views\Docs\Article.cshtml.bak.639273615833682148
- [FILE] Views\Docs\Index.cshtml
- [FILE] Views\Docs\Index.cshtml.bak.639273610427101065
- [FILE] Views\Docs\Index.cshtml.bak.639273615329883474
- [FILE] Views\Docs\Index.cshtml.bak.639273616218142076
- [FILE] Views\Docs\Installation.cshtml
- [FILE] Views\Docs\Licensing.cshtml
- [FILE] Views\Docs\Licensing.cshtml.bak.639273620177728074
- [FILE] Views\Docs\Licensing.cshtml.bak.639273620356689749
.output" },
"description": "Apply the fix"
}
]
}
Key features:
- Output chaining - Steps can reference
$stepN.outputfrom previous steps - Agent assignment - Each step targets a specific agent
- Parameter validation - JSON schema validation before execution
- Parallel execution hints - Independent steps can run concurrently
Layer 3 — Agent Execution (Orchestrator)
The Orchestrator manages an agent pool (max 5 concurrent AppEngine instances). Each engine runs a reasoning loop up to MaxSteps iterations.
Execution Loop
- Observe - Receive task step or user message
- Reason - Call LLM with system prompt, history, and available tools
- Act - LLM outputs tool call →
ReasoningRouter→ targetIAgent - Observe Result - Agent returns
AgentResult(success/output/error) - Loop - Feed observation back to LLM until task complete or max steps
AppEngine
Each AppEngine instance maintains its own conversation history, token budget, and compression state. The Orchestrator assigns steps to available engines.
Fast-Path Bypass
Simple read/list commands are detected by regex and executed directly without LLM involvement:
"show me Program.cs"→code_editor.read_file"list files in src"→code_editor.list_directory"search for TODO"→code_editor.search_in_files
This reduces latency from ~2-5s to ~50-200ms for common exploration tasks.