We use cookies

We use cookies to ensure you get the best experience on our website. For more information on how we use cookies, please see our cookie policy.

By clicking "Accept", you agree to our use of cookies.
Learn more.

Routing

Routing classifies an incoming request and directs it to a specialist durable task. A single entry point handles all requests; the routing logic (an LLM call, a rule-based check, or a keyword match) determines which downstream task runs. Only one branch executes per request.

This pattern improves response quality because each specialist task has its own prompt, tools, and context optimized for that category. It also simplifies the caller: trigger one task and let the router decide where to send it.

When to use

ScenarioFit
Customer service (support vs. sales vs. billing)Good: distinct domains with different prompts and tools
Document processing (invoice vs. receipt vs. contract)Good: each type needs different extraction logic
Request triage (simple auto-reply vs. complex agent)Good: avoid expensive agent loops for easy questions
All requests follow the same pathSkip: no benefit from routing
Routing rules are simple and known at definition timeUse Parent Conditions in a DAG instead

How it maps to Hatchet

The router is a durable task. It spawns a classifier child task (or does classification inline), then spawns the matching specialist as a child run. Since each specialist is a separate durable task, they can have their own timeouts, retries, rate limits, and concurrency settings.

Routing decisions are checkpointed. If the worker dies after classification but before the specialist finishes, the router resumes and does not re-classify.

Step-by-step walkthrough

Define the classifier task

A separate task classifies the incoming message. This lets you observe the classification result and retry independently if the LLM fails.

Define the specialist tasks

Each specialist is a standalone durable task with its own prompt and tools. They run independently with their own timeout and retry settings.

Route with a durable task

The router classifies the message, then spawns the matching specialist. The classification result is checkpointed, so if the worker dies after classifying, it resumes and spawns the specialist without re-classifying.

Run the worker

Register all tasks and start the worker.

For simple routing based on input fields (not LLM classification), you can skip the classify task and route directly in the durable task body based on input.type or similar fields.

Routing vs. DAG branching

Routing (durable task)DAG Parent Conditions
Branch decided byRuntime code (if/else, LLM call)Declared conditions on parent task output
Use whenCategory is unknown until an LLM classifies itBranch criteria are known at workflow definition time
ObservabilityRouter + specialist appear as separate runsAll branches visible in the DAG graph

Next Steps