Zenaique

Why per agent allowed handoff targets lists are the cheap fix for ping pong loops

Flashcard·Medium·4.0 · 0·~30s·Asked atBainNeptune AiRunway
Attempt it
TL;DR

If the back transfer tool is not in B's tool list, the model cannot emit it; an ACL turns ping pong from a prompt problem into a structural impossibility.

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

Imagine a customer service desk where agent A passes a customer to agent B because B knows about returns. If B's only available transfer buttons are 'send to specialist C' and 'finish the ticket,' then no matter how confused the conversation gets, B cannot bounce the customer back to A. The button is not on the panel. The same logic applies to agent handoff tools: if the back transfer is not in B's tool list, the model simply cannot suggest it. The loop is not unlikely; it is impossible. A turn limit is the seat belt; the ACL is making the road have no U turn.

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.

Ping pong loops are one of the most common multi agent failure modes in 2026 production systems, and one of the easiest to fix correctly once you see the right defence. The fix is not a clever prompt or a sophisticated runtime check; it is a declarative ACL that removes the back transfer tool from the agent's tool list.

This answer walks through why ping pong happens, why prompt level defences degrade, how the OpenAI Agents SDK's allowed handoff targets list closes the loophole at the tool layer, and why this is a specific instance of a broader principle that runs through good multi agent design.

Why ping pong loops happen in the first place

A ping pong loop is a graph cycle between two agents. Agent A is asked something, transfers to B, B looks at the conversation, decides A is better positioned to answer, transfers back. A receives the transferred conversation, finds itself in the same position as before, transfers to B again. The cycle continues until something external stops it.

The root cause is ambiguity

Ping pong is almost always caused by a prompt or routing setup that is ambiguous about which agent owns the final response. Both agents have plausible reasons to defer to the other: A says 'B is the specialist,' B says 'A has the full context.' The model picks the polite move (transfer to the other) on each turn.

Why the model picks transfer over answering

In the model's training distribution, transferring is a low risk move. It avoids committing to a possibly wrong answer; it defers to a teammate. Under context pressure, this is a strong attractor. Even a well written system prompt cannot fully compete with thousands of examples of polite deferral.

The cycle compounds quickly

Each transfer adds a turn to the conversation, which adds context, which makes the ambiguity worse. The longer the cycle runs, the more confident the model becomes that transferring is the right move (because that is what the recent history shows). Without an external bound, the cycle runs until the token budget triggers.

Why prompt level fixes degrade
How the allowed targets ACL closes the loophole
Defence in depth and the broader principle
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.
python
from agents import Agent, handoff, Runner

# Specialist agents, terminals in the handoff graph
refunds = Agent(
    name="refunds",
    instructions="Process refund requests; finish the ticket when done.",
    handoffs=[],  # cannot transfer anywhere, DAG terminal
)

shipping = Agent(
    name="shipping",
    instructions="Answer shipping questions; finish the ticket when done.",
    handoffs=[],  # cannot transfer anywhere
)

# Triage agent, the only one allowed to dispatch
triage = Agent(
    name="triage",
    instructions="Route the user to the right specialist based on their request.",
    handoffs=[refunds, shipping],  # one way only, no back transfers
)

# refunds.handoffs is [] so transfer_to_triage is not in its tool list.
# The model cannot emit a back transfer. The cycle is structurally impossible.

result = await Runner.run(triage, "I need a refund for order 1234")
DefenceMechanismWhen it fires
Prompt instructionSystem prompt asks the agent not to transfer backOn most turns; fails under context pressure
Allowed targets ACLBack transfer tool is not in the agent's tool listAlways; structural impossibility
max_handoffs capRuntime aborts after N handoffs totalOnly after the loop has wasted N turns
State sentinelManual check in code on each transferBrittle; depends on author remembering to check

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

  • OpenAI Agents SDK ships allowed handoff targets as a first class field on the Agent constructor; production deployments in 2026 commonly enforce a DAG topology through this mechanism.
  • Customer support agent designs from teams using the OpenAI Agents SDK route triage to specialist agents with no back transfer, structurally preventing the most common ping pong case.
Sign in to see more production examples.

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

QHow would you handle a cycle that is legitimate, like a critic loop with bounded revisions?
A

Use a bounded counter in state and an explicit termination condition; the loop is part of the graph by design, but its iterations are capped explicitly rather than blocked by an ACL. The ACL prevents accidental cycles; the counter bounds intentional ones.

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 max_handoffs as the primary defence against ping pong loops and letting the loop burn the cap before something stops it, when an ACL would have made the loop impossible to start.

Sign in to see all red flags and common mistakes.

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

  • Why ping pong loops happen and what makes them structural rather than incidental

  • How allowed handoff targets translate to tool list entries the model sees

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