Zenaique

How a talk loop between two agents starts and the cheapest hard stop for it

Flashcard·Easy·4.0 · 0·~30s·Asked atCerebrasTrueraZoho
Attempt it
TL;DR

Ambiguous role boundaries plus missing handoff ACL start the ping-pong; a max_handoffs cap is the cheapest hard stop, with tighter prompts and a pruned handoff graph as the real fix.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Picture two coworkers in adjacent cubicles. A says 'this is really B's job, I will pass it over'. B looks at it and says 'no, this is A's specialty, I will pass it back'. Neither wants to commit, and the file flies back and forth all afternoon. The cheapest fix is a manager who walks by after the fifth round and says 'stop, just finish it'. The proper fix is rewriting both job descriptions so it is clear who owns this kind of task and removing the option to bounce it back. Multi-agent ping-pong is the same office comedy with LLMs.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Talk loops are the canonical failure mode of swarm-style multi-agent topologies. Two agents (or more) hand the same task back and forth without making progress, burning tokens and frustrating users until something stops them. The pattern is so well-known that every serious framework ships a runtime cap to stop it, which is why this question is rated as a fundamentals check rather than a senior trap.

The answer has two parts. The first is correctly diagnosing the cause: ambiguous role-boundary prompts plus a handoff graph that allows cycles plus no termination rule in the prompts. The second is correctly naming the cheapest hard stop: a max_handoffs cap enforced by the runtime, with the explicit caveat that this is the floor, not the fix.

One-line summary: ping-pong starts in the prompts and dies at the cap. Three layers of defence: tight prompts, pruned graph, runtime cap. The cap is the floor.

How a talk loop actually starts

The minimal reproduction

Agent A's system prompt: 'You are a research specialist. If the user asks for analysis, hand off to the analysis agent.' Agent B's system prompt: 'You are an analysis specialist. If the user asks for research, hand off to the research agent.'

User query: 'Research the multi-agent framework landscape and analyse which is best for our use case.'

A receives, sees 'analyse', hands to B. B receives, sees 'research', hands to A. A receives, sees 'analyse', hands to B. Loop.

Why the loop happens

Three contributing causes are present and worth naming separately:

  • Ambiguous role boundaries. The handoff triggers in both prompts overlap. The task genuinely touches both areas, and neither prompt specifies ownership for that case.
  • Missing termination criteria. Neither prompt has a 'if you have already received this task once, commit and finish; do not hand off again' rule.
  • Open handoff graph. The framework allows A to hand to B and B to hand to A, so the cycle is structurally possible. An allowed-targets ACL that omitted one of those directions would have made the loop impossible at the graph level.

Multi-agent variants

Three-agent cycles (A to B to C to A) are harder to spot by reading individual prompts because no single pair contains the cycle. Detection has to look at the handoff trajectory, not just the prompts.

The runtime cap as the cheapest hard stop
Why prompts and ACL are the real fix
Production detection and the interview signal
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

Real products, models, and research that use this idea.

  • OpenAI Agents SDK exposes `max_turns` on Runner and `handoffs=[...]` on Agent precisely to address this failure mode.
  • LangGraph supervisor templates avoid the cycle structurally because workers return to the supervisor, not directly to peers.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow would you actually prune the handoff graph to make cycles impossible?
A

Model the allowed handoffs as a directed graph and require it to be acyclic (a DAG). If A can hand to B, B's handoff list excludes A; B can instead escalate to a terminal 'reviewer' or 'human' agent. Verify acyclicity in your test suite by graph traversal.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Treating the cap as the fix rather than the floor. A cap stops the bleeding; only tightened prompts and a pruned handoff graph prevent the wound.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • What a swarm topology is and why it is prone to loops

  • The three causes of talk loops (overlapping prompts, missing termination criteria, no ACL)

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Why AutoGen 0.4 makes TerminationCondition a first class primitive instead of leaving it to convention
Flashcard·Medium