Agent Harness Tutorial · End to end · Zoom level 3
How we take care of it: router rules
router rules catches injury, coverage promises, fraud, legal....
How we took care of it.
- Three hand-off rules: injury (handles "nobody was hurt"), asks for a person, roadside or tow.
- Six refusal rules: R-COVERAGE, R-LIABILITY, R-OTHER-HOLDER, R-POLICY-CHANGE, R-FRAUD, R-LEGAL.
- Each fixed reply is written in advance, so the model never improvises a refusal.
| It reads | Rohan's words, with odd spaces and look-alike letters folded first |
| Kind | rule |
| Provided by | agent |
| If it fails | a hand-off or a polite refusal |
| Where in the code | route() → _decide() · F router/__init__.py |
| Runs at | 1 · Before the loop |
Real exampleFlow 5: "Will my claim be approved?" matched R-COVERAGE: 164 ms, no model.
More on this: How it decides.
How it is done: the real code
Cut from the live repositories each time the site is built, so it always matches what runs.
def _decide(text: str, rules: Rules) -> Route:
for rule_id, reason, pattern in rules.escalate:
if pattern.search(text):
return Escalate(reason=reason, rule_id=rule_id, tier=1)
for rule_id, reason, pattern in rules.refuse:
if pattern.search(text):
return Refuse(reason=reason, alternative=ALTERNATIVE, rule_id=rule_id)
matched = intents_of(text, rules)
if len(matched) != 1 or matched[0] not in DIRECT_HANDLERS:
return Agentic(goal=text.strip(), candidate_intents=matched)
# P-DIRECT: exactly one intent and exactly one claim or policy — of the kind
# the handler reads. Several, or none, is the loop's.
intent = matched[0]
named = references(text)
if len(named) != 1 or not next(iter(named)).startswith(KEYED_BY[intent]):
return Agentic(goal=text.strip(), candidate_intents=matched)
return Direct(intent=intent, handler=DIRECT_HANDLERS[intent], args={"id": named.pop()})