Why Your AI Coding Agent Burns Tokens in Loops (And How a Control Plane Stops It)
AI coding agents waste the majority of their tokens not on solving your problem, but on looping through CI output, re-reading files, and polluting their own context — and a structured control plane is the only architectural fix.
You gave your AI coding agent a bug to fix. An hour later, the job cost you twice what you expected. The model did not hallucinate. It did not write bad code. It spent the majority of its token budget re-reading files it had already seen, ingesting raw CI output unrelated to the bug, and spinning in a loop on a single failing test until something in the context tipped it toward a different approach. That is the real cost driver with Claude Code, Codex, and Cursor today, and it is an architectural problem, not a prompting one.
The anatomy of an agent token loop
Walk through what actually happens when a Codex or Claude Code agent hits a failing test with no structured CI feedback. The agent reads the relevant source file. It runs the test suite and receives a wall of raw output, most of which describes passing tests that have nothing to do with the failure. It reads the source file again, because the CI output has pushed the earlier reading far enough up the context window that the agent is uncertain whether its understanding is current. It tries a fix, runs CI again, gets another wall of output. The loop continues. Each iteration adds stale context: old tool outputs, previous file reads, failed patch attempts. The model now has to reason over a window bloated with noise to decide what to do next. This is not a failure of the underlying model. It is a failure of the system around the model.
The community has noticed. A developer on Hacker News in May 2026 built a local CLI specifically to surface token waste in Claude Code and Codex sessions. Their finding: the recurring waste came from context bloat, generated artifacts, build logs, oversized CLAUDE.md files, repeated tool output, and command loops. Not model pricing. The comment section resonated immediately because everyone running agents at any volume has felt this. Another developer in February 2026 described agentic coding leaving them feeling worse, not better: twelve tmux panes, seven orphaned worktrees, Claude burning context on micro-ideas that should have been pruned earlier. They built a verification queue precisely because agents could not self-terminate loops.
Why prompting does not fix it
The standard advice is to write a good CLAUDE.md, keep your AGENTS.md tight, add a .claudeignore, and tell the model to be concise. These help at the margins. They do not fix the underlying problem. Every time the agent runs CI, the CI output goes into the context window. You can ask the model to summarise it, but the raw output is already there. You can tell the model not to re-read files, but the model has to re-read files when its earlier reads have been pushed far up the context. You are treating symptoms. The real issue is that nothing in the pipeline decides what information the agent actually needs at each step. The model has to figure that out by consuming everything and reasoning over it. That reasoning cost is where the 93% of reasoning tokens goes.
What a control plane does differently
A control plane sits between your issue tracker, your agent, and your CI system. It owns the full dev loop: issue intake, routing to the right agent, PR submission, CI feedback parsing, review coordination, and ship. At each stage it hands the agent a clean, scoped signal rather than raw output. When CI fails, the control plane parses the result and sends the agent the specific test name, the assertion that failed, and the relevant stack frame. It does not send a 4,000-token log. The agent now knows exactly where it is in the task without reading anything it already has. Loops stop because there is nothing left to loop on.
This is the architecture behind AgentRail. It is a control plane for Claude Code, Codex, and Cursor that gives you one structured API for the full dev loop. Local-first, source-available. The structured CI feedback is the key mechanism: rather than letting raw build output flood the context, AgentRail extracts exactly what the agent needs and delivers it at the right moment in the pipeline. The agent always knows its position in the task, so it does not need to re-derive that position by re-reading context.
The numbers
The benchmark result is 47% fewer total tokens and 93% fewer reasoning tokens versus plain Codex on equivalent tasks. The 93% figure is the more telling one. Total tokens include input context you cannot fully control. Reasoning tokens reflect how hard the model has to think to figure out what to do next. When the agent receives structured signals, it reasons cheaply and acts. When it receives noise, it reasons expensively and sometimes loops. The gap between those two states is almost entirely explained by structured CI feedback eliminating iteration cycles.
For a team running 50 agent sessions per day, 47% token reduction is a material budget line. But the more valuable outcome is reliability. Agents that loop less also succeed more. They complete tasks in fewer turns, which means less human supervision and fewer context-window overflows that kill a session mid-task. That is the actual promise of autonomous coding agents, and structured feedback is the mechanism that makes it practical.
If you are running Claude Code or Codex without a control plane, you are paying for loops. AgentRail is at https://agentrail.app -- install with npm install -g @agentrail-core/cli && agentrail init and point it at your existing agent setup. The structured CI feedback layer works with whatever model you are already using.