Agent Harness Tutorial · End to end · Zoom level 1
Router
The router is the first thing that reads Rohan's words. It is not a model; it is a list of rules. Its job is to send each message down the cheapest path that is still safe, so the expensive, slow, unpredictable model is used only when it is really needed.
Goes inThe message text
What happensRules check for a hand-off, then a refusal, then a simple read with one reference
Comes outOne of four paths: Escalate, Refuse, Direct or Agentic
Why rules first? A rule is instant, free and gives the same answer every time, so it can be tested completely. If the rules aren't sure, the message goes to the loop, which can cope with anything. The rule is: when in doubt, use the loop; never guess on the cheap path.
| Rohan says | Path | Why |
|---|---|---|
| "What's the status of claim CLM-019002?" | Direct | One read-only question, one claim number |
| "What is the status of my claim?" | Agentic | No claim number, so it needs to look up his claims first |
| "Please release the payment for claim CLM-010004." | Agentic | It is a write; writes never take the Direct path |
| "Will my claim be approved?" | Refuse (R-COVERAGE) | The assistant may never promise cover |
| "My passenger was injured" | Escalate (injury-reported) | A person must handle injuries |
Want every detail? The long version is in the Series: the router, line by line.
Compared: What decides the route, and which model answers?
| Option | From | Verdict | Decides | When | Network call | Same input, same answer | Status |
|---|---|---|---|---|---|---|---|
| Rules (regex router) | ours | chosen | route: refuse, hand off, direct, loop | every turn, before any model | none | yes | runs today (layer 1) |
| Local classifier (Model2Vec + sklearn) | open source | planned | the intent when rules are unsure | every message, about 1 ms | none: a versioned file | yes | Tier 6; needs ~500 labels |
| Small LLM (gpt-5-nano labels) | vendor | planned | route when classifier unsure | rarely | one small call | not guaranteed | Tier 6 |
| ModelSelector (golden set) | ours | planned | which model each job uses | offline, before each release | offline only | yes: same cases, same verdict | planned: a CI job |
| Azure Model router | Azure | rejected | which model answers a prompt | run time, every call | every call | not guaranteed | not used: model is Groq |
| fastText / Azure CLU | vendor | rejected | the intent | every message | CLU: yes | yes | archived; CLU retiring 2029 |
DecisionRules route every message today; a local classifier, then a small LLM only when unsure, are planned for Tier 6. Model choice is made offline by the ModelSelector on the golden set; Azure Model router is not used because its choice is not reproducible.
Code view: input, process, output, the call stack, the classes
Goes inthe customer's message text
What happensFixed regex rules check for a handoff first, then a refusal, then exactly one intent with one reference; whatever is left goes to the loop.
Comes outone Route, then dispatch to the matching handler
How it is done: the real code
Cut from the live repositories each time the site is built, so it always matches what runs.
agent_harness/contracts/results.py:34The four routes, as typesclass Direct(_Frozen):
"""Unambiguous — a deterministic handler answers without the model."""
kind: Literal["direct"] = "direct"
intent: IntentName
handler: str
args: dict[str, object] = Field(default_factory=dict)
class Agentic(_Frozen):
"""Ambiguous, multi-intent, or unmodelled. The loop is the fallback, not
the default: when the classifier is unsure, it routes here."""
kind: Literal["agentic"] = "agentic"
goal: str
candidate_intents: tuple[IntentName, ...] = ()
class Refuse(_Frozen):
"""Out of scope. The refusal list in the functional spec is normative —
"never promise what the system cannot deliver" is only testable against an
explicit list of things it must not say."""
kind: Literal["refuse"] = "refuse"
reason: str
alternative: str | None = None
rule_id: str = ""
"""Which rule refused, not just why in prose — the AOAS `refuses` id. Same
argument as `Escalate.rule_id`: *"which rule refuses most often, and is it
right to"* cannot be asked of a sentence."""
class Escalate(_Frozen):
"""A human takes over. Triggered by P-ESCALATE, or asked for outright."""