L'architettura Router-Worker separa Classificazione delle Intenzioni, Pianificazione delle Attivitàe Esecuzione degli Agenti in tre livelli distinti. Questo permette una scorciatoia per le richieste semplici mantenendo la piena autonomia per i compiti complessi.
Livello 1 — Classificazione dell'intento (IntentRouter)
Il messaggio originale dell'utente viene classificato in un Tipo di intento e Forma del piano con una sola chiamata LLM che produce esattamente due token (es. EDIT TASKLIST).
Tipi di intento
| Intento | Forma del piano | Descrizione |
|---|---|---|
Conversational | DirectAnswer | Saluti, chiacchiere, domande sullo stato |
CodeAnalysis | DirectAnswer | Esplorazione in sola lettura, ricerca, spiegazione |
CodeEdit | TaskList | Operazioni di scrittura, correzioni, refactoring |
ShellTask | TaskList | Comandi di build, test e compilazione |
KnowledgeQuery | DirectAnswer | Architettura, pattern, "cosa fa X" |
FileStatsCount | DirectAnswer | Conteggio righe, dimensioni, verifiche di esistenza |
Unknown | TaskList | Ambiguo, si ricade sul ciclo completo dell'agente |
Forme del piano
DirectAnswer- Una sola risposta dell'LLM, nessuno strumento necessarioTaskList- Piano strutturato con passaggi eseguibili
Livello 2 — Pianificazione del compito (TaskPlanner)
Per gli intenti TaskList , il planner compila un concreto TaskPlan con passaggi che supportano il concatenamento degli output tramite $stepN riferimenti.
Struttura di TaskPlan
{
"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
Livello 3 — Esecuzione degli agenti (Orchestrator)
L'Orchestrator gestisce un pool di agenti (massimo 5 istanze 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→ destinazioneIAgent - 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.
Scorciatoia per le richieste semplici
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.