Lesson 3 of 4
Detecting Delegation Cycles
Estimated time: 10 minutes
A depth limit bounds how tall the tree gets, but it does not stop a tree from folding back on itself. Two helpers can hand the same task to each other, and at every individual hop the decision looks local and sensible. The loop only becomes visible from above, which is precisely the view that no single agent in the pair has.
The fix is to carry lineage with the work. Each delegated task gets a unique identifier, and it also carries the list of identifiers above it. Before spawning, the orchestrator checks whether the task it is about to create already appears in that chain. If it does, the spawn is refused and the work is reported back rather than passed onward. This turns a subtle mutual recursion into a single comparison.
Lineage also earns its place when something goes wrong. When a deep run misbehaves, the chain of identifiers is the record of how the work actually moved, which is far more useful than a flat log of calls that all look the same. It is the difference between knowing that a task ran twice and knowing that it ran twice because two helpers kept handing it back.
The pairing matters. Depth alone catches runaway growth. Lineage alone catches loops but not breadth. Together they describe the shape of the run, which is what a bound is really for.