Architecture Pattern

Router-Supervisor Pattern

The router-supervisor pattern uses a central agent to dynamically route tasks to specialized workers and oversee their outputs for quality.

What Problem It Solves

Complex tasks often require different capabilities: - Research needs search and evaluation skills - Writing needs composition and style control - Analysis needs data processing and reasoning - Formatting needs structural transformation

A single general-purpose agent may perform adequately at all tasks but excel at none. Specialized agents excel at specific tasks but can't handle variety. The router-supervisor pattern combines the benefits: a generalist routes to specialists.

How It Works

Router Analyzes incoming tasks and determines which worker agent(s) should handle them. The router understands worker capabilities and task requirements, making routing decisions based on task classification.

Worker Agents Specialized agents optimized for specific task types. Each worker has focused prompts, appropriate tools, and potentially different underlying models suited to their specialty.

Supervisor Reviews worker outputs for quality before passing to the next stage or returning to the user. The supervisor can accept output, request revision, or escalate to human review.

When to Use / When to Avoid

Use when: - Your application handles diverse task types - Specialized agents significantly outperform generalists - You have clear criteria for routing decisions - Quality oversight is important

Avoid when: - Task types are uniform (no routing needed) - Specialization doesn't meaningfully improve quality - Latency is critical (routing adds overhead) - You're early in development (validate with simpler approaches first)

Failure Modes

Routing errors: Tasks sent to wrong specialists produce poor results. Mitigation: include confidence in routing; fallback to general agents when uncertain.

Supervisor bottleneck: All outputs flowing through one supervisor creates throughput limits. Mitigation: parallelize supervision or use sampling.

Inconsistent quality: Different workers produce outputs with varying style/quality. Mitigation: clear output specifications and supervisor normalization.

Escalation floods: Too many edge cases escalate to human review. Mitigation: improve routing and worker capabilities based on escalation patterns.

Esy Implementation Example

Esy's essay generation workflow uses router-supervisor for the writing phase:

Router analyzes each paragraph requirement (introductory hook, evidence presentation, analysis, transition, conclusion) and routes to appropriate specialists.

Writing Workers include: Hook Writer (engaging openings), Evidence Integrator (source incorporation), Analyst (interpretation and argument), and Synthesizer (conclusions and connections).

Supervisor reviews each section for quality criteria (clarity, evidence use, logical flow) and either approves, requests revision, or flags for human review.

This allows each writing component to be optimized independently while maintaining coherent overall output.