Agent Auth Gateway v1.0

Guides / 7 min read

How to Control Spend in AutoGen Multi-Agent Chats

Published 2026-11-14 · Reviewed 2026-11-14 · By the Ingenious AI team

AutoGen's strength — agents that keep talking until a problem is solved — is also its billing shape. Two agents in a group chat do not need a broken tool to spend money; they only need to disagree politely, forever.

The short answer

Bound an AutoGen conversation in three places: a maximum number of turns per conversation, a per-speaker daily spend cap keyed to each agent's own identity, and a termination rule that is checked by the authorisation layer rather than by one of the speakers. Speaker-selection loops and code-execution retries are the two expensive failure shapes, and both are invisible in a provider dashboard until the conversation ends. A gateway that evaluates each call before it runs sees the burn rate live and can refuse the turn that crosses the cap.

Check your own setup as you read: run the free Spend Guard self-check or test a policy in the playground — five minutes, no signup, and the gaps it names map to the controls below.

Worked example: the code-review chat that ran 41 hours

Pell & Vane, a fictional 14-person software consultancy, used an AutoGen group chat — a coder, a reviewer and an executor — to fix failing builds overnight. A normal night cost $6 to $9 and took under 300 turns. One Thursday the executor's test environment began failing every run for an unrelated licence reason; the coder kept proposing fixes, the reviewer kept accepting them, and the executor kept reporting the same failure in new words. The chat ran 41 hours, 12,930 turns, and $386.75 in model calls before a partner noticed on Saturday.

The consultancy kept the overnight workflow and bounded it. Conversations now end at 600 turns unless a human extends them. The executor's identity carries a $15 daily cap, the coder $20, the reviewer $12, and any conversation whose burn passes $25 routes its next turn to approval instead of auto-continuing. The licence failure recurred a month later; the chat stopped at turn 600 after $21.90 and 3 hours, left a complete transcript in the audit log, and the partner fixed the licence over coffee instead of reading an invoice.

Turns are the unit that matters first

In a chat framework, cost follows turns more faithfully than it follows time. A turn cap is therefore your primary control and the easiest to reason about: nobody's legitimate conversation needs to be ten times longer than your longest successful one. Measure completed conversations, take the 95th percentile, and set the ceiling near twice it. When the ceiling is hit the conversation should stop cleanly and summarise what it has — a bounded partial result is worth far more than an unbounded eventual one.

Per-speaker caps catch asymmetric loops

Not every loop is symmetric. An executor retrying code, or a speaker-selection model that keeps choosing the most expensive specialist, can burn most of the budget while other speakers stay quiet. Per-speaker caps keyed to separate identities make that asymmetry visible and stoppable: the executor hits its own ceiling while the reviewer and coder remain available for other work. With a shared key, the same event is just 'the account spent $386' with no culprit and no scoped remedy.

Termination rules belong outside the chat

Asking a participant to decide the conversation is over fails exactly when the conversation is the problem — speakers are selected to continue, and a looping pair will keep finding one more thing to say. Termination by turn count, by elapsed budget and by repeated identical tool results should be enforced by the layer that authorises calls, which has no stake in continuing. Keep human extension one tap away so a genuinely long, productive run is an approval, not a rewrite.

Repeated-failure detection is a cheap, early signal

The most valuable detector in the worked example would have been the simplest: the same tool returning the same failure class many times in a row. Count consecutive identical failures per conversation; at a threshold you choose — ten is a sane start — hold further calls for approval. Healthy agents rarely fail identically ten times. Looping agents almost always do, and they do it early, while the spend is still in single figures.

Putting numbers on your own conversations first

Before changing any AutoGen configuration, export a week of conversation logs and compute three distributions: turns per conversation, turns per speaker, and cost per completed conversation. Most teams discover their median conversation is a tenth the length of their longest, and that one speaker — usually the one with tools — accounts for most turns. Those three distributions set every number in this guide for your fleet: the turn ceiling at twice the 95th percentile, per-speaker caps from each speaker's own burn, and the mid-run tripwire where healthy conversations almost never go. Recompute them after a month of enforcement; AutoGen workloads drift as prompts and tools evolve, and a ceiling fitted to last quarter's conversations quietly becomes this quarter's false alarm.

Five actions to bound AutoGen spend today

  1. Set a hard maximum turn count per conversation, near twice your longest successful run.
  2. Give each speaker its own identity and daily spend cap, sized from its observed normal burn.
  3. Move termination enforcement out of the chat: turn, budget and repeated-failure rules checked at authorisation time.
  4. Hold a conversation for human approval when its burn crosses a mid-run tripwire instead of letting it auto-continue.
  5. Log every turn's speaker, action and estimated cost so any night's spend can be attributed in one query.

Source note and related guides

Figures in the worked example are illustrative, drawn from a fictional company created for this guide; the controls, failure patterns and procedures described are the gateway's documented behaviour — see the Agent Auth Gateway documentation and the policy patterns in allowlists vs denylists, spend caps and the agent kill switch. Reviewed by the Ingenious AI team, 2026-11-14.

Sources

  • OpenAI API documentation — Rate limits and spend limits, on how provider-side usage and spend limits are defined at organization and project level: platform.openai.com, 2026
  • NIST AI Risk Management Framework (AI RMF 1.0), the voluntary framework for managing AI risk across design, development and use: nist.gov, 2023
  • OWASP Top 10 for Large Language Model Applications, the OWASP GenAI Security Project's risk list for LLM and agent systems: owasp.org, 2025

Frequently asked questions

How do I stop an AutoGen chat from running forever?

Enforce a maximum turn count and a per-conversation budget outside the chat, at the authorisation layer. Do not rely on a speaker to terminate — in a loop, the speakers are the mechanism that keeps it going.

What is a good turn limit for a group chat?

Measure your completed conversations and set the ceiling near twice the 95th-percentile length. Pell & Vane's normal nights ran under 300 turns, so 600 became the cap, with human extension available.

Why give each AutoGen speaker its own cap?

Loops are often asymmetric — one executor or one repeatedly selected specialist burns most of the budget. Per-speaker identities make the culprit visible and let you stop that speaker without killing the whole system.

How do I detect a looping conversation early?

Watch three signals: turn count against the ceiling, burn rate against the conversation's own baseline, and consecutive identical tool failures. The third usually fires first and cheapest.

Can a human extend a capped conversation?

Yes — that is the design. Hitting the cap routes the next turn to approval; a person who can see real progress extends it deliberately, and the extension is logged like every other decision.

Governing agents in production?

Spend caps, approval queues, policy simulation, burn forecasting, and step-up lockdowns — all built into the gateway. Free tier to start. Or test policies in the playground with no signup.

Share this: X Facebook LinkedIn WhatsApp
← How to Set Spend Limits for a CrewAI Cre… All guides How to Add Spend Guardrails to the OpenA… →