Agent Smart Routing - Meta-Agent Dispatcher
Overview
PlanExe's planning pipeline currently uses a single agent profile for all stages. As plans grow in complexity and domain diversity, different stages benefit from specialized agents optimized for specific tasks (research, writing, technical validation, creativity).
This proposal introduces a meta-agent dispatcher that routes each pipeline stage to the most appropriate agent based on stage type, domain, and requirements.
Problem
-
Generic agents produce mediocre results across all domains
-
No way to leverage specialized models (reasoning models for analysis, fast models for formatting, etc.)
-
Pipeline stages have different cost/quality trade-offs that aren't exploited
Proposed Solution
Architecture
┌─────────────────┐
│ PlanExe Core │
│ (Orchestrator)│
└────────┬────────┘
│
v
┌─────────────────┐
│ Meta-Agent │ ← Dispatcher logic
│ Router │
└────────┬────────┘
│
├──→ Research Agent (Gemini 2.0 Flash)
├──→ Writing Agent (Claude Sonnet)
├──→ Technical Agent (GPT-4 + reasoning)
└──→ Format Agent (Haiku/Fast model)
Routing Rules
Store routing configuration in llm_config/<profile>.json:
{
"agent_routing": {
"research": {
"model": "google/gemini-2.0-flash-thinking-exp",
"reason": "Fast, cheap, good at web search synthesis"
},
"outline": {
"model": "anthropic/claude-sonnet-4",
"reason": "Strong at structure and planning"
},
"technical": {
"model": "openai/gpt-4-turbo",
"thinking": "enabled",
"reason": "Deep reasoning for complex technical content"
},
"format": {
"model": "anthropic/claude-haiku-4",
"reason": "Fast, cheap, reliable for formatting"
}
}
}
Implementation
-
Add
AgentRouterclass inbackend/mcp_cloud/src/routing/ -
Modify pipeline stages to call
router.get_agent(stage_type, domain) -
Add telemetry to track agent selection and performance per stage
-
Build admin UI to override routing rules per-customer
Benefits
-
15-30% cost reduction by using fast models for simple stages
-
Quality improvement from specialized agents
-
Flexibility for customers to bring their own agent configs
-
A/B testing different agent combinations per stage
Risks & Mitigations
| Risk | Mitigation |
|---|---|
| Increased complexity | Start with 3-4 agent profiles, expand gradually |
| Debugging harder | Add detailed logging of agent selection |
| Config drift | Validate routing config on startup, fail fast |
Next Steps
-
Prototype with 3 agents (research, writing, format)
-
Run side-by-side comparison on 20 existing plans
-
Measure cost savings and quality delta
-
Ship behind feature flag, enable for beta customers
Success Metrics
-
Cost per plan decreases by 20%+
-
User satisfaction rating increases (via post-plan survey)
-
No increase in pipeline failure rate
Detailed Implementation Plan
Phase A — Routing Contract and Registry
- Define an explicit routing contract in
run_plan_pipeline.pywith: - stage name
- routing signal inputs
- selected agent class
- fallback class
- Build an agent registry file (YAML/JSON) mapping capabilities to stages.
- Add deterministic routing mode for reproducible runs.
Phase B — Dynamic Selection Engine
- Implement router scoring using:
- stage complexity
- domain type
- latency/cost budget
- Add weighted scoring for each candidate agent and choose top-ranked.
- Add confidence threshold to trigger fallback routing when uncertain.
Phase C — Observability and Controls
- Emit route decisions as structured events.
- Track route success/failure by stage.
- Add policy overrides for forced agent selection in sensitive flows.
Validation Checklist
- Deterministic routing under fixed seeds
- Correct fallback activation under low confidence
- Route-quality lift vs static baseline