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
When oscillation trips, stop — do not “try a stronger model” in a loop without a new plan hash.
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]
Human after N rounds
typescript
❌ “Keep going until ACCEPT” with no human path — that is how weekend bills appear.
// 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" };
}
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.
Most viewed
- Python Decorators Explained: From Simple Wrappers to Production Patterns
- Claude Code vs Cursor vs GitHub Copilot: Choose by Workflow, and Set Up One Repo That Works With All Three
- AI Agent Frameworks in 2025: LangGraph vs CrewAI vs AutoGen vs Raw API
- Python String Methods: Every str Method With Real Production Examples
- Css Animation Performance: Performance-Optimized Motion for Modern UIs
Newly added
- AWS Systems Manager Parameter Store: Hierarchical Runtime Config for Coding Agents
- Amazon Cognito Identity Pools: Federate Coding-Agent Tool Callers Without Long-Lived Keys
- Amazon Athena for Coding Agents: Query Tool Audit Logs and Eval Traces on S3 Without a Warehouse
- AWS Batch for Coding Agents: Parallel Overnight PR Reviews and Long-Running Jobs Without Lambda Timeouts
- Amazon Bedrock Prompt Management: Version and A/B Test Coding-Agent System Prompts
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.
