A journal of architectural patterns, failure modes, and design principles for engineers building AI agents that run continuously at scale.

Detecting and Resolving Agent Deadlock in Collaborative Pipelines

Two types of agent deadlock demand different detection and recovery strategies.

· 9 min read
Cover illustration for “Detecting and Resolving Agent Deadlock in Collaborative Pipelines”
Multi-Agent Coordination · October 17, 2026 · 9 min read · 1,918 words

Agent deadlock in collaborative pipelines needs two different responses because it takes two different forms. Classical resource cycles stop agents from moving forward, while LLM re-planning loops keep them busy without getting any further. Reliable recovery starts by identifying which failure is happening, then applying detection and recovery controls that match it.

Why agent deadlock in collaborative pipelines is harder to diagnose than it looks

A stalled pipeline does not reveal its cause just by looking stalled. In a classical resource cycle, Agent A holds something that Agent B needs, and Agent B holds something that Agent A needs. Neither can proceed, so both wait. In an LLM re-planning loop, an agent continues reasoning and calling tools, but each new approach returns to the same broken dependency. The first failure has a circular wait, while the second can happen inside a single agent with no dependency cycle at all.

That distinction matters because activity is not the same as progress. A quiet pipeline may be stuck waiting for a resource, while a busy one may be spending money on attempts that cannot succeed. Calling both classical deadlock sends engineers looking for cycles that may not be there. Treating both as ordinary timeouts misses retries that happen inside the model’s reasoning. The label matters less than the mechanism behind it.

How classical resource-cycle deadlock forms in multi-agent pipelines

A strict order for hand-offs can lead to a resource cycle. Consider a three-agent summarization pipeline where agent 2 waits for agent 3’s classification before emitting its cleaned output. Agent 3 needs that cleaned output before it can classify anything. Each agent’s next step depends on the other finishing first. No single agent can satisfy that arrangement on its own, and the pipeline halts.

The tighter those hand-offs become, the shorter the path from one stalled agent to a blocked workflow. Chandra et al. show how tight spaces can lead to deadlock in multi-robot navigation. Constrained pipeline topologies present a similar structural problem when agents have no independent way forward. The Databricks orchestration guide identifies documented input/output contracts as a prerequisite for unambiguous routing between agents.

Decentralized pipelines can also stop through coordination conflicts. Two agents may claim the same shared task or produce contradictory outputs. That is not a wait cycle, even if the visible result is another halted pipeline. Keeping the distinction clear matters because settling ownership is a different problem from breaking a dependency.

How the LLM re-planning loop forms and why it looks like normal operation

A re-planning loop starts when a tool call fails or times out and the model tries another approach. It changes parameters or chooses another tool, but the new route reaches the same broken dependency. Because the requests differ, each retry can look like a fresh attempt. Ordinary retry counters stay low while reasoning consumes tokens and paid tool calls add cost.

An OpenClaw idle-timeout bug led to 761–1,384 model calls within 60 seconds across two real incidents. A Claude Code session with a saturated context window sent repeated requests for hours after a compaction attempt, producing a large unexpected bill. These failures show how sustained activity can hide the absence of useful progress. The agent keeps producing requests, so a monitor that only asks whether it is running gets the wrong answer.

A dependency graph cannot expose this loop because there is no circular wait between agents. The model is searching for a route around a failure without finding one. Detection therefore has to look inside the execution context.

What production failures actually look like: cost, corruption, and cascade

The damage falls into three categories, namely cost blow-outs, pipeline corruption, and cascading failures. Cost grows when individually reasonable calls accumulate without a limit on the whole workflow. The engineering concern is the rate of accumulation.

Corruption adds a different cost because an agent may repeat an external action as well as use up tokens. A retry loop operating as designed posted 47 nearly-identical messages to a public channel before anyone noticed, with no circuit breaker written to stop it. Public posts, sent emails, and committed transactions cannot be treated as reversible internal steps. Stopping the loop does not undo what it already sent.

Failures can also cascade when repeated calls hit a dependency used elsewhere in the pipeline. Those calls add latency and waste reasoning tokens, and they put other work at risk. Crew Scaler’s MAS security taxonomy identifies Timing and Monitoring as a risk category because observability gaps allow failures to cross agent boundaries before an alert fires. These risks call for controls that keep failures from spreading without waiting for someone to step in.

Detecting classical deadlock: graph-based cycle detection and watchdog coverage

Classical detection starts with a directed graph of active waiting relationships. Model each Wait_agents relationship as an edge from the waiting agent to the agent it needs. Check for a cycle that persists across time steps within a defined detection window. A circular wait provides the structural signature for this failure mode. A timeout or an unsatisfied Wait_entity predicate does not, and belongs in separate handling logic.

Logging state lets the detector look at more than one snapshot. LLMDR, by Seo et al., offers a related window-based approach, but its detector should not be mistaken for a graph cycle check. It analyzes agent positions and trajectories for behavior such as no movement or goal-less wandering, then classifies and groups deadlocked agents. Its useful operational lesson is to identify the affected group before choosing a response.

Watchdogs provide a coarser safety net around that targeted detection. They monitor expected execution windows and force a timeout or reassignment when a task stalls. This coverage matters most in sequential workflows, where one missing output blocks the next hand-off immediately. Documented input/output schemas give the orchestration layer the contracts it needs to interpret those missing outputs.

Detecting the LLM re-planning loop: what to instrument when the graph looks clean

When no cycle appears, the next question is whether successive attempts repeat the same effective action. Use a rolling detection window to compare calls with progress. Warning signals include rising call volume to one endpoint with flat success counts, changing parameters that converge on the same dependency, and accelerating token consumption without completed subtasks. None of those signals requires a circular wait. Their common feature is activity without an advance in pipeline state.

To expose that pattern, log each tool call’s semantic intent, including its target endpoint and action category, alongside its raw parameters. If N calls within T seconds resolve to the same failing dependency, flag a possible re-planning loop regardless of graph state. A hard call-rate cap per agent per minute supplies a backstop before deeper analysis finishes.

For services that host agents per customer, including Agent37, this means adding instrumentation inside agent sandboxes as well as using external dependency graphs. An isolated execution context is where repeated tool invocations and token consumption can be tied to one agent’s progress. Isolation supplies a boundary for observation, but it does not replace the monitor.

Resolving classical deadlock: cycle-breaking, priority reassignment, and conflict arbitration

Once a cycle is confirmed, choose recovery according to the affected group and the dependencies it holds. Where grouped agents support LLM-driven priority reassignment, the LLMDR pattern offers targeted intervention. LLMDR assigns priorities, then uses Priority Inheritance with Backtracking (PIBT) to generate collision-free single-step moves in its pathfinding setting. The transferable principle is to resolve the blocked group while leaving unblocked agents running. It is not a reason to restart the entire pipeline.

Where that orchestration is unavailable, a watchdog-forced timeout is a practical fallback. Time out the longest-waiting agent in the cycle and reassign its held resource. This breaks a wait at one edge rather than trying to optimize the whole group’s path. The intervention belongs to the confirmed cycle.

If the problem is conflicting claims in a decentralized pipeline, use arbitration instead. Voting protocols, priority rules, and timestamp-based arbitration address disputed ownership or contradictory outputs. The Databricks orchestration guide recommends human approval gates for high-risk actions. Where recovery involves irreversible messages or transactions, human review should precede automated resolution.

Resolving the LLM re-planning loop: circuit breakers, retry budgets, and backoff

A re-planning loop needs an infrastructure boundary that the model cannot bypass by proposing another approach. Put a circuit breaker around the failing dependency and track recent failures. When consecutive failures cross the threshold, the breaker opens and stops calls to that service. OpenClaw’s response to its runaway retry incident used this pattern to cap consecutive idle-timeout model calls.

Configure the breaker before tuning its supporting retry controls. A standard production configuration trips after five consecutive failures, enters half-open after 30 seconds, and closes only if a single probe succeeds. The open state also needs an explicit fallback, such as notifying a human, scheduling a retry in one hour, or recording a do-nothing default.

Next, apply exponential backoff with jitter to permitted retries. Start at one second, double on each attempt, cap at around 30 seconds, and add a random offset. Without jitter, agents that fail together retry together and amplify the original failure.

Finally, share a retry budget across the workflow. A per-call limit caps one step, but the total number of attempts can grow when each step retries on its own. A shared budget makes earlier retries reduce what remains for later steps.

Applying both detection tracks together in a production pipeline

Run the two detection tracks in parallel because both failures can occur in the same pipeline. The graph detector watches active Wait_agents relationships, while the call-rate and semantic-intent monitor watches what agents do within a rolling window. Watchdogs cover agents with bounded expected execution times when the targeted detectors miss a stall. Each signal then routes to its matching recovery path.

Agent37 provisions an isolated, persistent agent per customer via a single API call, with each sandbox having its own filesystem and a hard disk quota. That makes it an option for programmatic per-customer provisioning without configuring each environment by hand. Filesystem isolation should remain distinct from workflow controls that prevent one session from consuming another’s retry budget or API quota.

Scheduled work also belongs in this operational model. A sandbox that sleeps between invocations can miss scheduled steps, leaving downstream agents waiting for a hand-off that never happened. Always-on sandboxes avoid these failures because they stay awake. As more customers join, detection and recovery have to be automatic because recovering every persistent agent by hand does not scale.

What to instrument before the first deadlock happens

Before deployment, write down every agent’s input/output contract and the longest time it is expected to take. Set the same timing baseline for every hand-off. Assign explicit ownership to each shared resource or task slot so that neither circular waits nor coordination conflicts hide behind undocumented state.

At launch, wire in rolling dependency-graph logs and a hard call-rate cap per agent per minute. Put a circuit breaker on every external dependency, with a documented fallback action. Set a retry budget shared across all steps in the workflow. Log tool-call intent and progress so that changes to parameters cannot hide failures that keep happening.

For external writes, messages, and transactions, route automated recovery through a human approval gate until the failure modes are well characterized. Enforce these boundaries automatically across customer environments rather than configuring recovery separately after each incident. The goal is a pipeline that loses minutes and a few tokens when its first deadlock arrives, rather than hours, money, and sometimes customer trust.

Sources

  1. LLMDR: LLM-Driven Deadlock Detection and Resolution in Multi-Agent Pathfinding
  2. Multi-Robot Navigation in Social Mini-Games: Definitions, Taxonomy, and Algorithms
  3. Security Considerations for Multi-agent Systems

More in Multi-Agent Coordination