Definition
The Dispatcher distributes requests to agents, workflows, or tools, and maintains task state, retry, timeout, and routing policy. It is more engineering-focused than a Router and more of a system component than a Supervisor.
Category: Control structure
When to use
Internal platforms, long-running tasks, multi-tenant agent services, systems that need resumable scheduling and unified policy.
When not to use
One-off demos, single-agent chat, or lightweight tasks with no state-recovery requirement.
How to implement
- Design the Dispatcher as a service layer — not as an LLM agent.
- On every request, create a task / run / session and write a checkpoint.
- Choose sync execution, async queue, workflow, or handoff based on policy.
- Reduce agent results to a uniform status:
success / blocked / need_input / failed. - Centralize retry, cancel, timeout, and budget at the Dispatcher.
Minimal pseudocode
TypeScript
type DispatchDecision = {
mode: "agent" | "workflow" | "tool" | "ask_user";
target: string;
async: boolean;
reason: string;
};
async function dispatch(req: UserRequest) {
const run = await runs.create(req);
const decision = await router.decide(req, policy.allowedTargets(req));
return scheduler.schedule(run, decision);
}
Recommended trace events
dispatch.request.createddispatch.decision.madedispatch.scheduleddispatch.completed
Common failure modes
- Dispatcher starts writing complex prompts — it becomes an opaque agent.
- No task/run/session layering.
- Retry policy scattered inside each agent.
Implementation checklist
- Trigger and exit conditions defined.
- Input/output schemas defined.
- Permission, budget, timeout, and retry policies defined.
- Trace events defined.
- Degradation or human-takeover strategies defined.