Agent Harness Tutorial · End to end · Zoom level 3
How we take care of it: Tier-2 hand-off rules
Tier-2 hand-off rules catches declined, loop exhausted, tool down, second refusal, 10+ turns.
How we took care of it.
- Six rules: declined, loop exhausted, tool unavailable, the same intent repeated, a second refusal, 10 or more turns.
- Any of them starts a DBOS hand-off to a person.
| It reads | the whole turn and the conversation's counters |
| Kind | rule |
| Provided by | agent |
| If it fails | hand to a person |
| Where in the code | F escalation/rules.py · H entrypoint/handoff.py:191 |
| Runs at | 7 · After the loop |
Real exampleFlow 19: turn 10 fired turns-exceeded and raised E-8E24C2A1.
More on this: 19 · A long conversation.
How it is done: the real code
Cut from the live repositories each time the site is built, so it always matches what runs.
DEFAULT_RULES: tuple[Tier2Rule, ...] = (
Tier2Rule(
id="declined",
when=(Condition(field="termination", equals=("declined",)),),
reason="a payout the policyholder's account can no longer receive",
priority=1,
ttl_s=30 * 60,
),
Tier2Rule(
id="loop-exhausted",
when=(Condition(field="termination", equals=TERMINATED_BADLY),),
reason="the agent could not complete this and stopped",
priority=2,
ttl_s=15 * 60,
),
Tier2Rule(
id="tool-unavailable",
when=(Condition(field="consecutive_failed", at_least=2),),
reason="the claims system is not responding",
priority=2,
ttl_s=15 * 60,
),
Tier2Rule(
id="repeated-intent",
when=(Condition(field="repeated_intent", at_least=3),),
reason="the policyholder has asked for the same thing three times without resolution",
priority=3,
ttl_s=30 * 60,
),
Tier2Rule(
id="second-refusal",
when=(Condition(field="refusals", at_least=2),),
reason="the agent has refused this policyholder twice and a person should decide",
priority=4,