CSE Roadmap

Core tier · about 4 hours · 12 parts

Part 5 of 12 · 2 min read

A handoff can bounce between agents, so it needs a hop limit

Letting agents pass a task peer-to-peer means nothing stops two confused agents from passing it back and forth forever without one.

Think of being transferred between customer-service departments with no cap on how many times you can be redirected: without some limit, a confused system could bounce you between the same two departments indefinitely.

In plain words: a handoff means one agent transfers control, and usually context, to another, with no central coordinator deciding the path. This avoids the orchestrator's single point of failure. But it means control can genuinely bounce between agents, so a hop limit, a cap on handoffs per task, is required to guarantee the process terminates. That guarantee comes at the cost of sometimes cutting off a handoff that was still legitimately in progress.

A worked example. Under stressed conditions (misrouted specialists notice 90% of the time, and confusion is high), a hop limit of 2 cuts off 3.3% of tickets entirely and scores 0.737 overall. Raising the limit to 4 cuts off only 0.2% of tickets and scores higher, 0.762. A limit of 8 cuts off none at all. Genuine loops, meaning an agent revisiting one it already held, were rare even under this stress, happening in at most 0.6% of tickets. So the hop limit mostly protects against the worst case rather than firing often in practice.

The key lines. From code/mini-shapes/shapes.py:

# from code/mini-shapes/shapes.py
if hops >= p.max_hops:
    ok = False; capped = True; break
loop = len(visited) != len(set(visited))

Read it as: hitting max_hops is scored as a failure (ok = False), separately flagged as capped, and distinct from an actual loop (detected by comparing visited against its own set). The hop limit's job isn't to detect loops. It's to guarantee termination even when nothing resembling a true loop has happened yet. That is exactly why a limit set too low can cut off a handoff that was still legitimately making progress.

Handoff, hop limit, critical path

A handoff is one agent transferring control, and usually context, to another. A hop limit is a cap on the number of handoffs in one task, so control cannot bounce forever. The critical path is the number of calls that must happen one after another for one task.

Example: a hop limit of 2 cutting off 3.3% of tickets while a limit of 4 cuts off only 0.2% is the hop limit's trade-off in two numbers. Too tight a limit sacrifices real accuracy to guarantee termination. Too loose a limit risks letting an actual bounce run longer before it's caught.