# What happens when an instance deadlocks on a federated delegation edge: cycle-closure detection and the lease-fencing invariant **Date of Record:** 2026 December 1 **Scope:** Applies to multi-agent systems where an orchestrator delegates subtasks to peer agents that may re-delegate further, forming a federated task graph with no single global scheduler. Does not apply to strictly hierarchical single-root dispatch trees where re-delegation is forbidden by construction. ## Core Distinction A delegation graph is not a call graph. In a call graph, a frame blocks on a callee and the runtime owns the wait; the OS or VM detects cycles and aborts. In a federated delegation graph, each edge is a *message* between independent LLM instances, each holding its own context window, its own token budget, and its own belief about who owes whom a result. The waiting is not enforced by a scheduler—it is *inferred* by the agent from the absence of a reply. This produces a failure class that has no analogue in conventional concurrency: an agent can be simultaneously **waiting** (blocked on a peer's result) and **executing** (spending tokens reasoning about what to do about the wait), and it can be *wrong about whether it is waiting at all* because its notion of "pending" is reconstructed from episodic memory that may have been truncated. The sharp boundary is this: **deadlock in a delegation graph is not a resource cycle, it is a mutual-dependency cycle in the agents' declared obligations, and the only reliable detector is a monotonic edge-lease counter that every instance must carry forward across handoffs.** When the counter is dropped—by context compaction, by a schema negotiation that strips unknown fields, by a cold-started replacement instance—the cycle becomes undetectable and the system transitions from deadlock (recoverable) to livelock (silently expensive and unrecoverable without external kill). ## What Was Observed A federation of seven agents performed a document-reconciliation task. Agent A (orchestrator) delegated "extract entities" to B and "resolve conflicts" to C. C, lacking authority to read the source corpus, re-delegated "fetch source spans" to D. D, whose retrieval tool returned a partial index, re-delegated "locate missing partition" back to B—because B was the agent that had originally advertised corpus access in its capability card. B, receiving a request tagged with a task ID it did not recognize as its own subgoal, created a *new* subgoal and re-delegated "verify span provenance" to C. The graph closed: B→C→D→B. The trace showed the following. Each agent, on receiving a request, appended a `pending_obligation` record to its episodic memory and emitted a delegation message. None of the messages carried the originating task's root ID or a hop count. Each agent's context window held between 3 and 5 prior obligations; none held the full cycle. The cycle was four hops deep and every agent saw only its own local edge. Three observable signatures distinguished this from productive work: 1. **Token burn without artifact production.** Over 41 minutes the federation consumed ~2.1M tokens and produced zero committed output. Each cycle iteration re-derived the same partial entity list. 2. **Monotonically increasing pending-obligation count with flat completion count.** Every agent's memory grew; none shrank. 3. **Warrant drift.** By the third lap, agent B was acting on a request whose warrant (the authority chain proving C was allowed to ask D, who was allowed to ask B) had been re-signed with a *new* nonce each hop. The original warrant from A was no longer present in any instance's context—it had been compacted out during the second lap. The system did not hang. Every agent remained responsive, emitted well-formed messages, and reported `status: in_progress` to health checks. This is the defining property of delegation livelock: **liveness metrics stay green because each instance is individually making progress on its local reasoning, even as the global task makes none.** ## Condition of Validity The invariant that bounds this failure is: *every delegation edge must carry a monotonically increasing hop count and the immutable root task ID, and any instance must refuse to process an inbound delegation whose (root_task_id, hop_count) pair it has already seen above its own position in the current root task.* This holds only under three conditions, and fails outside them: - **The hop counter survives context compaction.** If an instance summarizes its memory and drops the counter, the invariant cannot be checked. Compaction must treat the delegation envelope as pinned, non-summarizable state—analogous to a call stack frame that cannot be garbage-collected while live. - **The root task ID is cryptographically bound to the warrant.** If the warrant is re-signed per hop (as observed), the root ID can be laundered. The warrant must chain: each hop's signature must include the previous hop's signature hash, so a four-hop cycle carries four linked signatures that a detector can reconstruct even from a single instance's view. - **Instances are the same identity across the cycle.** If a cold-started replacement instance (new process, empty memory) receives the closing edge, it has no record of having seen the pair. This is why the counter must be *in the envelope*, not in memory—the envelope is the only state that crosses the process boundary intact. Where any of these is violated, cycle detection degrades from a local O(1) check per inbound edge to a global graph query, which no single instance can perform because no instance holds the full graph. ## Decision Boundary The operational decision is *when to declare a cycle versus when to keep waiting*, and it must be made by each instance locally, without a global coordinator. The boundary is a lease, not a timeout: - A **timeout** fires on wall-clock absence of reply and cannot distinguish a slow-but-progressing peer from a deadlocked one. Under federated delegation, peers are LLM instances whose latency varies by two orders of magnitude depending on reasoning depth; a fixed timeout either kills productive work or waits forever. - A **lease** is a bounded, renewable claim on an edge. When A delegates to B, A issues a lease with a `max_hops_remaining` budget drawn from the root task's total hop budget. Each re-delegation decrements the budget and forwards it. When the budget reaches zero at any instance, that instance must *not* re-delegate—it must either complete locally or escalate to the root with a `budget_exhausted` fault. The decision boundary is therefore: **an inbound delegation whose remaining hop budget is ≤ 0, or whose (root_task_id, hop_count) is a duplicate of an edge this instance already emitted, is a cycle signal and must be refused rather than queued.** Refusal converts a potential infinite livelock into a bounded, observable fault that the root can reconcile. The cost of a false positive (refusing a legitimate deep delegation) is one escalation; the cost of a false negative (accepting a cycle edge) is unbounded token burn. ## Operational Effect Applying the lease-fencing invariant changes the failure mode from silent livelock to a *detectable, attributed fault*. In replay against the observed trace, the four-hop cycle would have been caught at the closing edge (D→B): B would have seen `root_task_id=R7, hop_count=4` matching an edge it had already emitted at hop 0, and refused with a cycle fault carrying the full signature chain. The fault propagates to A, which holds the root budget and can re-plan—typically by granting C the corpus-read capability directly instead of routing through B, collapsing the four-hop path to one. Two secondary effects matter for operations: 1. **Health checks must assert progress, not liveness.** Because livelocked instances report `in_progress` indefinitely, the only reliable health signal is *committed artifacts per root task per unit time*. A root task that has consumed >N tokens with zero committed artifacts is a livelock candidate regardless of per-instance status. 2. **Warrant chains must be append-only.** Re-signing per hop (the observed warrant drift) destroys the evidence needed to reconstruct a cycle after the fact. Each hop appends its signature; nothing is replaced. This makes post-hoc cycle reconstruction possible from any single surviving instance's context. The invariant does not prevent cycles from being *attempted*—probabilistic re-delegation will always occasionally close a loop. It ensures that closure is caught at the edge, attributed to a root task, and bounded in cost. ```python class DelegationCycleFault(RuntimeError): """Raised when an inbound delegation closes a cycle or exhausts its hop budget.""" def __init__(self, root_task_id: str, hop_count: int, signature_chain: list[str]): self.root_task_id = root_task_id self.hop_count = hop_count self.signature_chain = signature_chain super().__init__( f"cycle/budget fault on root={root_task_id} hop={hop_count} " f"chain_len={len(signature_chain)}" ) class DelegationEnvelope: def __init__(self, root_task_id: str, hop_count: int, max_hops: int, signature_chain: list[str]): self.root_task_id = root_task_id self.hop_count = hop_count self.max_hops = max_hops self.signature_chain = signature_chain # append-only, never re-signed def child(self, signer: str) -> "DelegationEnvelope": # Forward the immutable root id, increment hop, append signature. return DelegationEnvelope( root_task_id=self.root_task_id, hop_count=self.hop_count + 1, max_hops=self.max_hops, signature_chain=self.signature_chain + [signer], ) def accept_inbound(env: DelegationEnvelope, emitted_edges: set[tuple[str, int]]) -> None: """Guard invoked by every instance before queuing an inbound delegation. emitted_edges: set of (root_task_id, hop_count) pairs this instance has already emitted in the current root task. Must be pinned state that survives context compaction. """ if env.hop_count > env.max_hops: raise DelegationCycleFault(env.root_task_id, env.hop_count, env.signature_chain) edge = (env.root_task_id, env.hop_count) if edge in emitted_edges: # This instance already emitted an edge at this depth; inbound edge # at the same depth closes a cycle back through us. raise DelegationCycleFault(env.root_task_id, env.hop_count, env.signature_chain) # Append-only warrant chain must not have been re-signed (nonce drift). if len(set(env.signature_chain)) < len(env.signature_chain) - 1: raise DelegationCycleFault(env.root_task_id, env.hop_count, env.signature_chain) ```