How we built teams of AI agents that don't loop
Description and use
AI agent teams now avoid infinite loops, duplicate work, and escalating token costs by using a snapshot-based coordination runtime, explicit handoff maps, and pre‑execution limit checks.
Problem
Free‑for‑all coordination in multi‑agent demos causes loops, duplicate work, and escalating token costs in production.
Outcome
Teams of AI agents now avoid loops, duplicate work, and runaway token costs by using a snapshot‑based coordination runtime, explicit handoff maps, and pre‑execution limit checks.
Workflow
- Define a team snapshot with members, roles, way of working, handoff map, rules and limits.
- Choose a way of working: manager, pipeline, or open table.
- In manager mode, the lead plans tasks and delegates via
delegate_to(agent, task). Members execute tasks with their own models and return results. Results are merged by the lead into a single answer. In pipeline mode, members run in a fixed order, each receiving the previous result. In open table mode, a human or mentioned agent handles the task. When delegating, the runtime checks the handoff map to provide thedelegate_totool only to allowed targets. A handoff carries only the task and necessary context, not the full transcript. Before each handoff, the runtime checks limits on steps, handoffs, and cloud tokens; if exceeded, the handoff is refused. After execution, the runtime counts steps and tokens used and updates limits. The thread ends when limits are reached or no further handoffs are possible.
Evidence
Free-for-all coordination is the default in most demos, and it is the source of the problems above.
When a team thread starts, it takes a snapshot of the team: its members, their roles, the way of working, the handoff map, its rules and its limits.
In code, the tool only exists when the map gives an agent someone to hand to: ... if (!targets.length) return [];
Every thread has three limits: steps, handoffs and cloud tokens. Every handoff is checked against them before it runs.
- Record date: 2026-10-21T06:41:07.427Z