Skip to content

Router-Worker Pipeline

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

IntentPlan ShapeDescription
ConversationalDirectAnswerGreetings, small-talk, status questions
CodeAnalysisDirectAnswerRead-only exploration, search, explanation
CodeEditTaskListWrite operations, fixes, refactoring
ShellTaskTaskListBuild, test, compile commands
KnowledgeQueryDirectAnswerArchitecture, patterns, "what does X do"
FileStatsCountDirectAnswerLine counts, sizes, existence checks
UnknownTaskListAmbiguous, fall back to full agent loop

Plan Shapes

  • DirectAnswer - Single LLM response, no tools needed
  • TaskList - 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.output from 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

  1. Observe - Receive task step or user message
  2. Reason - Call LLM with system prompt, history, and available tools
  3. Act - LLM outputs tool call → ReasoningRouter → target IAgent
  4. Observe Result - Agent returns AgentResult (success/output/error)
  5. 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.