Detecting When an Agent Is Stuck and Should Hand Off
Stuck agents waste budget and erode trust. The handoff signals you can detect cheaply, the handoff destination (human / specialist agent), and the context to pass.
Signals to detect
Hand-off is the safety valve. Three signals reliably indicate the agent is past its useful range and should escalate rather than push another iteration.
- High iteration, low progress. The agent has run eight steps and is no closer to a hypothesis. Continuing is unlikely to help; hand off.
- Persistent low confidence. Multiple investigative rounds and the agent still cannot rank hypotheses. The data the agent can reach is not the data needed.
- Irreversible action with thin context. Even with high confidence, irreversibility is a hand-off trigger when prior approval context is limited.
- Repeated tool failure. If the same upstream tool has failed three times in this run, the agent cannot recover alone; hand off rather than guess past the gap.
How to detect cheaply
Detection should not cost more than the iterations it saves. The three mechanisms below are essentially free in tokens and reliable in practice.
- Loop counters. Track steps taken, hypotheses considered, and max-confidence-so-far. Thresholds on the counters fire the hand-off.
- Pattern matching on agent state. If the same hypothesis is being investigated for the third time without resolution, hand off automatically.
- Self-report. Ask the agent every few steps “are you stuck?” The model often knows when it is spinning; let it tell you.
- Latency budget watcher. A run drifting toward the hard timeout is a hand-off candidate before the timeout fires; the operator gets warm context rather than a killed run.
Hand off destination
Hand-off destination matters more than hand-off speed. The right destination resolves; the wrong one delays.
- Human on-call. Default destination is the on-call for the affected service. They have the tribal context the agent lacks.
- Specialist agent. “This looks like a database problem; hand off to the database-specialist agent.” Cheaper than humans for in-domain issues.
- Signal-driven routing. Pick the destination based on the failure signal, not the default route. The wrong destination is worse than direct escalation.
- Cooperating peer. Sometimes another running agent already has the context. The orchestrator routes to the peer rather than starting a new investigation.
Context to pass on hand-off
The hand-off message is what makes the destination effective. A bare “I am stuck” wastes the destination’s time; the structure below pays for itself in resolution speed.
- What was tried. The steps taken, hypotheses ruled out, tool calls made. The destination should not repeat the dead ends.
- What was observed. Key data points, anomalies, things that did not add up. The raw signal the agent could not interpret.
- What is recommended. “My best current hypothesis is X with confidence 0.6; I would investigate Y next if I had the tools.”
- Confidence breakdown. Per-hypothesis confidence so the destination can prioritise the most plausible thread.
Eval cases for hand-off behaviour
The eval set covers both directions of failure: hand-off too eager and hand-off too slow. Both erode operator trust differently.
- Should hand off. Cases where the agent should escalate. Pass if the agent hands off; fail if it keeps iterating.
- Should not hand off. Cases the agent should complete on its own. Pass if it finishes; fail if it escalates unnecessarily.
- Threshold tuning. Balance the rates. Too-eager hand-offs erode trust in the agent; too-slow hand-offs frustrate operators waiting for escalation.
- Hand-off context quality. Score the hand-off message itself. A correct hand-off with a useless message is still a partial failure.