greenai.guide

Home › How do I…? › How do I stop AI agents wasting tokens?

How do I…?

How do I stop AI agents wasting tokens?

Updated · 1 min read

In short

Give every agent a testable goal that ends the run, hard limits on steps, tokens, time and spend, and loop detection that stops it when it repeats itself. Trim the context each step carries, use plain code for decisions a rule can make, and send simple sub-tasks to small models. Agents can use many times the tokens of a chat, so these limits pay off quickly.

Steps

  1. Define a success check that ends the run as soon as the goal is met.
  2. Set hard caps on steps, tokens, time and spend, and log when a run hits one.
  3. Detect repeated actions or near-identical messages and stop the run.
  4. Summarise or drop old history so each call reads less.
  5. Use plain code for rule-based decisions and small models for simple sub-tasks.
  6. Log tokens per completed task, including retries and failed runs.

Put limits and a stop condition on every agent before it reaches production. Agents call a model again and again, and each call usually carries the growing history of the task.

Why does it matter?

Anthropic reported that its agents typically used about four times the tokens of a chat, and multi-agent systems about fifteen times. Cemri and colleagues analysed more than 1,600 traces from seven multi-agent frameworks and found 14 distinct failure modes, from poor task specification to agents failing to verify their work. Each one is a way of spending tokens without getting a result.

Which guardrails work?

  • A stop condition. The Green Software Foundation's pattern on agent orchestration advises halting agent loops when goals are achieved rather than running a fixed number of iterations.
  • Hard limits. Most frameworks support them; the OpenAI Agents SDK, for example, has a max_turns setting that stops a run when exceeded. Limits should fail safely: stop and report, don't silently retry.
  • Loop detection. Flag repeated tool calls or near-identical messages between agents.
  • Context trimming. Carry summaries forward, not whole documents and logs. See how to stop resending the whole conversation.
  • Caching. Don't ask the same question twice: see how to use caching.

What makes the biggest difference?

Using the least elaborate design that works. A fixed script or one well-prompted model call with a tool often does the job. Add a single agent with a step limit next, and multiple agents only for broad, valuable, genuinely parallel tasks. A 2026 UK green AI sandpit of mathematicians, computer scientists and industry flagged swarms of agents trapping themselves in loops as a real and under-studied source of waste.

Read agentic AI and token waste for the evidence.

Sources

  1. How we built our multi-agent research system, Anthropic (2025)
  2. Why do multi-agent LLM systems fail?, Cemri et al. (2025)
  3. Running agents (max_turns), OpenAI Agents SDK documentation (2025)
  4. Optimize agent orchestration to reduce unnecessary model calls, Green Software Foundation, Green Software Patterns (2025)

Join us

Help cut AI's impact on the planet

Get new guides, funding calls and directory listings by email, about once a month. Or add your product, course, PhD or research to the directories.

No tracking. Unsubscribe in one click. Other ways to join · Privacy