Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Lesson 4 of 6 · Concept · 15 min · revision 3

How Multi-Agent Systems Fail

Diagnose the four coordination failures of multi-agent systems (lost context at a handoff, conflicting actions, runaway delegation and duplicated work), each with a detection signal, and add the limits and checks that contain them.

Contentsand lesson path

What you will learn

  • Diagnose multi-agent failure modes (lost context, conflicting actions, runaway delegation, duplicated work) and add limits and checks.

Prerequisites: Agent Loops & ReAct

01. Why it matters

When a single agent fails, the failure usually sits in one place: a tool call raises an exception, the context overflows, or the model draws a wrong conclusion. You read one trace, find the step and fix the prompt, the tool or the code.

A multi-agent system adds a second kind of failure: agents that each do something reasonable can still fail together. A supervisor forgets to pass a constraint to a worker. Two workers update the same record. Two agents hand a ticket back and forth for an hour. Three workers search for the same papers. None of these needs a single model mistake, and none of them shows up as an error span.

Researchers who studied this found the same pattern. Cemri et al. (2025) identified 14 failure modes in three categories (system design issues, misalignment between agents, and weak verification of results) from 150 traces annotated by experts, then built a dataset of more than 1,600 annotated traces from seven multi-agent frameworks. Anthropic reports that early versions of its research system spawned 50 sub-agents for simple queries and that, without detailed task descriptions, sub-agents duplicated work or left gaps.

This lesson covers the four coordination failures you will meet first. For each one you learn what it looks like, the signal that detects it in traces or logs, and the limit or check that contains it.

02. Four Coordination Failures, How to Spot Them and How to Contain Them

  1. Lost context at a handoff. A worker or a receiving agent misses something the sender knew. For example, the supervisor knows the customer is on an EU data plan and delegates "find a storage vendor", and the worker recommends a vendor that stores data only in the US. The worker did its task well; it was never told the constraint. Detection: compare the delegation brief, which the trace records as the input of the worker span, with the user request; a grader that checks the final answer against the original constraints flags the violation. Containment: delegate with a structured brief that names the goal, the constraints, the inputs, the expected output schema and the boundaries of the task, and refuse to dispatch a brief that leaves a field empty. With a handoff, which passes control instead of returning a result, pass the relevant history or a summary that keeps every constraint.

  2. Conflicting actions. Two agents change the same resource, or give the user contradictory instructions. One agent upgrades a customer to the pro plan while another, working on a refund, sets the same customer to free; whichever writes last wins, silently. Detection: two write spans on the same resource ID in one trace, especially close together, or two final messages that disagree. Containment: give each resource one owning agent (a single writer) and let the others send it requests; or take a lock or lease before writing; or use version checks, where every write names the version it read and a stale write is rejected.

  3. Runaway delegation. Agents keep delegating without finishing. Two peers hand a ticket back and forth (ping-pong), or sub-agents spawn sub-agents of their own until a simple question has used dozens of agents. No step raises an error, so nothing stops the run by itself. Detection: the delegation depth, the number of agents and the token spend keep growing while no new findings come back; the list of transitions shows a repeating pattern such as A, B, A. Containment: hard limits enforced by the orchestrator, outside any model: a maximum number of handoffs, cycle detection, a cap on agents per run and a token budget for the whole run, with escalation to a person when a limit trips. A sentence in the prompt asking agents to delegate less is a request, not a limit.

  4. Duplicated work. Two workers do the same sub-task, because the split was vague or because a task was dispatched again after a retry. You pay twice, and the merged result lists the same finding twice or, worse, two slightly different versions of it. Detection: identical tool calls with the same arguments from different agents, or duplicate items in the merged output. Containment: give each worker a distinct, written scope; keep a task ledger with an ID and a status per sub-task, and refuse to hand out an ID that is already running or done; deduplicate when merging.

Two related patterns make these worse. When agents share one broadcast channel and every agent answers every message, message volume grows much faster than the number of agents. And in a pipeline, a wrong value from one agent is trusted by the next, so validate each output against a schema or the source before passing it on.

03. The Guards in Code

The circuit breaker below contains runaway delegation. validate_handoff allows at most max_hops handoffs and catches A, B, A cycles. Its cycle rule is stricter than the handoff guard in lesson 2. That guard allows one return trip, billing to account and back, and escalates only when the same handoff repeats. This breaker escalates on any immediate return. The strict rule stops a loop one hop sooner, but it also stops a user who really does need billing, then account, then billing again; it suits agents whose domains should not overlap. record_spawn caps the number of agents at any depth. record_tokens enforces the token budget: the orchestrator calls it after every model call of every agent, with the usage reported in the response, and it raises BudgetExceeded as soon as the run goes over. Run the file to see the cycle check and the token budget trip.

Python · guards/breaker.py
"""Orchestrator-side limits against runaway delegation."""


class BudgetExceeded(RuntimeError):
    pass


class CoordinationCircuitBreaker:
    def __init__(self, max_hops=4, max_agents=6, max_tokens=50_000):
        self.max_hops, self.max_agents = max_hops, max_agents
        self.max_tokens = max_tokens
        self.visited, self.agents, self.cumulative_tokens = [], 0, 0

    def validate_handoff(self, current, next_agent):
        """Return the agent to run next, or escalate on a hop limit or a cycle."""
        self.visited.append(current)
        if len(self.visited) > self.max_hops:  # allow max_hops handoffs, then stop
            return "escalate_to_human"
        if len(self.visited) >= 2 and self.visited[-2] == next_agent:
            return "escalate_to_human"  # A -> B -> A: ping-pong
        return next_agent

    def record_spawn(self):
        """Call before starting any sub-agent, at any depth."""
        self.agents += 1
        if self.agents > self.max_agents:
            raise BudgetExceeded(f"agent cap {self.max_agents} reached")

    def record_tokens(self, n):
        """Call after every model call of every agent, with usage from the response."""
        self.cumulative_tokens += n
        if self.cumulative_tokens > self.max_tokens:
            raise BudgetExceeded(
                f"{self.cumulative_tokens} tokens, budget {self.max_tokens}")


if __name__ == "__main__":
    breaker = CoordinationCircuitBreaker()
    print("billing -> subscriptions:",
          breaker.validate_handoff("billing", "subscriptions"))
    print("subscriptions -> billing:",
          breaker.validate_handoff("subscriptions", "billing"))
    for n in (30_000, 18_000, 3_000):
        try:
            breaker.record_tokens(n)
            print(f"+{n} tokens: total {breaker.cumulative_tokens}")
        except BudgetExceeded as exc:
            print(f"+{n} tokens: BudgetExceeded: {exc}")
Terminal (Python 3.12 or later, standard library only)
python3 breaker.py
Expected output
billing -> subscriptions: subscriptions
subscriptions -> billing: escalate_to_human
+30000 tokens: total 30000
+18000 tokens: total 48000
+3000 tokens: BudgetExceeded: 51000 tokens, budget 50000

The second file holds one check for each of the other three failures. check_brief refuses a delegation brief with an empty field, which catches a forgotten constraints list but cannot tell whether the list is complete; a grader that checks the final answer against the user request covers that. TaskLedger refuses to hand out a sub-task that is already claimed. VersionedStore rejects a write based on a stale read, so the second agent learns about the conflict instead of silently overwriting the first.

Python · guards/coordination.py
"""Checks against lost context, duplicated work and conflicting writes."""

BRIEF_FIELDS = ("goal", "constraints", "inputs", "output_schema", "boundaries")


def check_brief(brief):
    """Refuse to delegate a task whose brief leaves out a required field."""
    missing = [field for field in BRIEF_FIELDS if not brief.get(field)]
    if missing:
        raise ValueError(f"brief is missing {missing}")
    return brief


class TaskLedger:
    """One entry per sub-task ID; a claimed or finished task is not handed out again."""

    def __init__(self):
        self.tasks = {}

    def claim(self, task_id, agent):
        if task_id in self.tasks:
            owner, status = self.tasks[task_id]
            return f"{agent}: refused, {task_id} is {status} by {owner}"
        self.tasks[task_id] = (agent, "running")
        return f"{agent}: claimed {task_id}"


class VersionedStore:
    """A write must name the version it read; a stale write is rejected."""

    def __init__(self):
        self.rows = {}

    def read(self, key):
        return self.rows.get(key, (None, 0))

    def write(self, key, value, read_version, agent):
        current = self.read(key)[1]
        if read_version != current:
            return f"{agent}: rejected, {key} changed since version {read_version}"
        self.rows[key] = (value, current + 1)
        return f"{agent}: wrote {key} version {current + 1}"


if __name__ == "__main__":
    try:
        check_brief({"goal": "Find EU storage vendors", "inputs": ["budget.csv"]})
    except ValueError as exc:
        print("delegation:", exc)
    ledger = TaskLedger()
    print(ledger.claim("q2-pricing", "worker-a"))
    print(ledger.claim("q2-pricing", "worker-b"))
    store = VersionedStore()
    _, seen_a = store.read("customer-17")
    _, seen_b = store.read("customer-17")  # both agents read version 0
    print(store.write("customer-17", {"plan": "pro"}, seen_a, "agent-a"))
    print(store.write("customer-17", {"plan": "free"}, seen_b, "agent-b"))
Terminal
python3 coordination.py
Expected output
delegation: brief is missing ['constraints', 'output_schema', 'boundaries']
worker-a: claimed q2-pricing
worker-b: refused, q2-pricing is running by worker-a
agent-a: wrote customer-17 version 1
agent-b: rejected, customer-17 changed since version 0

04. Check your understanding

Practice check · 3 questions

Multi-agent failure modes check

Three scenario questions on detection signals, delegation briefs and enforced budgets.

Q1. Which signal in a multi-agent trace points to runaway delegation rather than another failure mode?
Q2. A supervisor knows the customer may only use EU data centres. It delegates "find a storage vendor", and the worker recommends a US-only vendor. Which change prevents this most directly?
Q3. Your orchestrator calls `record_tokens` only inside `validate_handoff`. One worker then loops on its own for 200,000 tokens without handing off. What happens with `max_tokens=50_000`?
Practice only: not graded, not saved, not evidence.

05. Apply it

In the research assistant you are building for this skill, add the guards before you add more agents:

  • Write the delegation brief as a structure with goal, constraints, inputs, output schema and boundaries, and reject a brief with an empty field.
  • Give each sub-question an ID in a task ledger, and deduplicate findings by source when merging.
  • Route every model call through record_tokens, and cap agents per run and delegation depth.
  • If any agent writes to shared state, give that state one owner or a version check.

Then run your ten questions and count how often each guard trips. A guard that trips often points to a design problem, not just a limit to raise.

06. Review prompt

Without looking back, name the four coordination failures covered here. For each, describe one signal that detects it in a trace and one check that contains it. Then explain why a token budget must be enforced by the orchestrator after every model call, rather than requested in a prompt.

References

Your progress

Reading state

Sign in to save that you finished reading this lesson.

Sign in to mark reading complete

Prove this skill

8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.
Take the skill check