multi-agent coordination: Avoiding Agent Ping-Pong

Day 53: Avoiding Agent Ping-Pong
5 views
This guide focuses on multi-agent coordination for production systems, with practical trade-offs for reliability, security, and cost. Two agents politely disagreeing for forty rounds is not “reasoning” — it is a token furnace. Production swarms need budgets, stop conditions, and a human gate after N rounds so ping-pong cannot become the default control flow.
⚡ TL;DR: Cap rounds, tokens, and wall-clock per run. Detect oscillation (repeated REJECT reasons). After N critic failures, route to a human with a one-page brief — never auto-loop overnight.

multi-agent coordination: production guidance

python
# runtime/budget.py
from dataclasses import dataclass

@dataclass
class RunBudget:
    max_rounds: int = 4
    max_tokens: int = 200_000
    max_wall_s: int = 900
    tokens_used: int = 0
    rounds: int = 0

    def charge(self, tokens: int):
        self.tokens_used += tokens
        if self.tokens_used > self.max_tokens:
            raise RuntimeError("budget_tokens_exhausted")

    def tick_round(self):
        self.rounds += 1
        if self.rounds > self.max_rounds:
            raise RuntimeError("budget_rounds_exhausted")

Detect oscillation

python
def oscillating(history: list[str]) -> bool:
    if len(history) < 4:
        return False
    # ✅ same reject fingerprint twice in a row pair
    return history[-1] == history[-3] and history[-2] == history[-4]
When oscillation trips, stop — do not “try a stronger model” in a loop without a new plan hash.

Human after N rounds

typescript
// gates/human.ts
export type Gate = { kind: "continue" } | { kind: "human"; brief: string };

export function afterCritic(rounds: number, verdict: { decision: string; evidence: string[] }): Gate {
  if (verdict.decision === "ACCEPT") return { kind: "continue" };
  if (rounds >= 3) {
    return {
      kind: "human",
      brief: `Stuck after ${rounds} rounds.\nEvidence:\n- ${verdict.evidence.join("\n- ")}`,
    };
  }
  return { kind: "continue" };
}
❌ “Keep going until ACCEPT” with no human path — that is how weekend bills appear.

Closing checklist

  • [ ] Enforce round + token + wall-clock budgets
  • [ ] Hash reject reasons; detect oscillation
  • [ ] Escalate to humans with a structured brief
  • [ ] Persist budget counters in the run record
  • [ ] Alert when runs hit caps frequently

Series navigation

Day 52: Blackboard vs Message Bus Orchestration · Day 54: Specialist Tools per Agent Last updated September 11, 2026 Related: Day 51: Multi-Agent Roles: Planner, Implementer, Critic; Day 59: Multi-Agent Eval: Task Suites, Not Vibes; Multi-Agent Systems: How to Build Agent Teams That Do Not Hallucinate Each Other Into Failure.

Watch: 100 Days of AI on YouTube

Short videos from CheatCoders, one AI engineering topic per day.

Open the playlist on YouTube · CheatCoders on YouTube

Deep-dive PDF

Get the expanded guide for this post — extra diagrams-style checklists, failure modes, and a production walkthrough. Free when you subscribe to CheatCoders.

Already subscribed? or open the subscribe page.


Discover more from CheatCoders

Subscribe to get the latest posts sent to your email.

Comments

No comments yet. Why don’t you start the discussion?

Leave a comment

No account needed. Name and email are optional.