Module 5 · Lesson 6 · 14 min read

Pitfalls of multi-agent systems

Multi-Agent Pitfalls

Introduction

A team that works well in a demo may collapse in real use. This lesson gathers the best-known pitfalls: loops, conflicting outputs, cost explosion, error amplification and injection spreading between agents, and offers a practical, programmable remedy for each.

Learning objectives

  • Recognize six common pitfalls in multi-agent systems
  • Estimate the team's cost in number of calls before running it
  • Apply a rounds and budget guard in simple code
  • Choose a suitable strategy for resolving conflicting outputs

Why do teams fail?

Every agent in the team is a probabilistic system that may make mistakes, and every message between two agents is a chance for misunderstanding. When we add agents we do not only add up their capabilities; we add up the probabilities of their errors too. So team design needs to think about failure from the start, not after it appears.

Six common pitfalls

  1. Infinite loop: a writer and a reviewer exchanging notes endlessly, or two agents each handing the task to the other.
  2. Conflicting outputs: two agents give two contradictory answers, and there is no rule that decides which one is adopted.
  3. Cost explosion: the number of calls multiplies with every agent and every round, and the response time may multiply with it.
  4. Error amplification: the writer builds confidently on a false piece of information from the researcher, then the reviewer lets it through because it seems consistent with the rest of the text.
  5. Role drift: an agent starts doing tasks outside its role, such as a reviewer rewriting the whole report.
  6. Injection propagation: malicious text in a web page read by the research agent turns into "instructions" inside its message to another agent that has wider permissions. This is an extension of the idea of indirect prompt injection described by Greshake and colleagues.

Estimating the cost before running

Before building the team, compute the upper bound on the number of calls. If you have a supervisor and three workers, and each worker may need up to three review rounds, the upper bound is roughly: a call for splitting, three workers over three rounds, a review for each round, and a call for aggregation. The numbers in the following example are hypothetical, for illustration only, and are not real prices:

python
def max_calls(workers, rounds, reviewer=True):
    per_round = workers + (workers if reviewer else 0)
    return 1 + per_round * rounds + 1  # splitting + rounds + aggregation

single_agent = 3            # an assumption: a single agent with three steps
team = max_calls(workers=3, rounds=3)
print("Single agent:", single_agent, "calls")
print("Team in the worst case:", team, "calls")
print("Ratio:", round(team / single_agent, 1), "times")

The result is 20 calls in the worst case against 3 for a single agent. This does not mean the team is wrong; it means you must know why you are paying this cost.

Programmable remedies

The rounds and budget guard

We wrap every interaction between agents in a guard that counts the rounds and calls and stops the work when either is exceeded, with a clear message instead of a silent stop.

Conflict resolution strategies

StrategyThoughtWhen it fits
PriorityA specific source or agent has the final sayWhen there is a trusted official source
VotingThe most frequent answer is adoptedQuestions with a definite answer
The judgeA third agent compares using evidenceWhen justification is needed
EscalationThe conflict is presented to a humanSensitive decisions

A practical example: three agents and an exam date

A student asked about the date of a course exam. Two agents answered "12 January" and a third answered "15 January", based on an old timetable. The following simulation combines the rounds guard with conflict resolution: priority to the official timetable if there is one, then voting, then escalation on a tie:

python
from collections import Counter

class Guard:
    def __init__(self, max_rounds, max_calls):
        self.rounds = self.calls = 0
        self.max_rounds, self.max_calls = max_rounds, max_calls

    def tick(self, calls=1):
        self.rounds += 1
        self.calls += calls
        if self.rounds > self.max_rounds or self.calls > self.max_calls:
            raise RuntimeError(f"Stopped: rounds={self.rounds}, calls={self.calls}")

def resolve(answers, official=None):
    if official is not None:
        return official, "Priority to the official source"
    (top, n), *rest = Counter(a for _, a in answers).most_common()
    if rest and rest[0][1] == n:
        return None, "Tie: escalate to a human"
    return top, f"Vote {n} of {len(answers)}"

guard = Guard(max_rounds=2, max_calls=6)
answers = [("agent_a", "12 January"), ("agent_b", "12 January"), ("agent_c", "15 January")]
guard.tick(calls=3)
print(resolve(answers))
print(resolve(answers, official="12 January"))
try:
    guard.tick(calls=3)
    guard.tick(calls=3)
except RuntimeError as e:
    print(e)

Notice that the guard does not just stop; it states the reason for stopping in numbers, which makes tracing easier later.

Trace every message

The most important diagnostic tool is tracing: recording every message, tool call and routing decision with its time and cost. Without tracing the question "Why did the team give this answer?" has no answer.

Summary

Teams usually fail because of loops, conflicting outputs, cost explosion, error amplification, role drift and injection spreading between agents. The remedy starts with estimating the upper bound on calls before running, and adding a rounds and budget guard. Conflicts are resolved by priority, voting, a judge or escalation to a human. And full tracing of messages is a condition for diagnosing any fault.

Terms

TermEnglishDefinition
Infinite loopInfinite LoopAn exchange of messages or handoffs between agents that never ends
Cost explosionCost ExplosionThe number of calls multiplying with agents and rounds
Error amplificationError AmplificationLater agents building on an earlier agent's error
Role driftRole DriftAn agent doing tasks outside its defined role
Indirect prompt injectionIndirect Prompt InjectionMalicious instructions hidden in content the agent reads
TracingTracingRecording messages, calls and decisions to diagnose behavior

Review questions

  1. How does prompt injection spread from a research agent to an agent with wider permissions?
  2. Compute the upper bound on calls for a supervisor, two workers and two rounds with a reviewer.
  3. When would you prefer escalation to a human to voting between agents?
  4. Why must the rounds guard state the reason for stopping instead of stopping silently?

References