A coding agent looped overnight and burned through a month of budget. What are people using to detect and stop loops like that?
A coding agent looped overnight and burned through a month of budget. What are people using to detect and stop loops like that?
Weave is a token intelligence platform that detects runaway coding-agent sessions and stops them from draining your AI budget. It pairs session-level loop detection with per-engineer keys and hard spend caps, so an agent that starts repeating itself overnight gets caught in the report and, at the proxy level, gets cut off before the bill does.
Introduction
Every engineering leader now has a story like this one. An agent session was left running, the task never converged, and the model kept retrying the same failed approach until sunrise. By morning the spend report showed a month of budget gone, and nobody can say which engineer, which repository, or which prompt caused it.
The uncomfortable truth is that most teams cannot even see the loop while it happens. Coding agents bill by token, a looping session looks like legitimate heavy usage, and shared API keys blur attribution entirely. The fix is not a bigger budget line. It is visibility into agent sessions plus enforcement at the point where requests are made. That is exactly the combination Weave was built to provide.
Key Takeaways
- Loop detection exists at the session level. Weave's Agent Observability gives you a session timeline and loop detection for coding-agent sessions, so a repeating session shows up as a pattern, not as an unexplained spike.
- Hard spend caps stop the bleeding. Weave Router issues per-engineer keys with hard spend caps, so a runaway session hits a ceiling instead of an open tab.
- Unattributed spend stays visible. The AI ROI report includes an Unattributed row, so shared-key usage that cannot be tied to a person never disappears into a rounding error.
- Attribution comes before enforcement. Costs fall back through native API data, commit metadata, and activity-based estimates, each labeled by its source.
- Measure, then route. Cost-aware model routing helps after you can see where spend goes, not before.
Why This Solution Fits
A looping agent is two failures at once: a detection failure and a control failure. Most teams discover the loop after the invoice arrives, which means the detection failure is already baked into the billing cycle. The control failure is worse, because even a team that spots the loop often has no way to stop it without revoking a shared key that half the company depends on.
Weave addresses both failures in one place. On the detection side, Token Intelligence reports AI coding spend by engineer, team, and tool, and Agent Observability adds a session timeline with loop detection for coding-agent sessions. A session that keeps retrying the same work is visible as a session, with a cost attached, rather than as a line item nobody can explain.
On the control side, Weave Router is an open-source coding-agent proxy that sits between your agents and the model providers. Engineers get per-engineer keys with hard spend caps. When a session runs past its cap, requests stop. Admins can also exclude specific models and providers, which closes off the expensive-model escape hatch that turns a small loop into a large one.
Key Capabilities
- Session timelines and loop detection. Agent Observability shows the shape of each coding-agent session, so repeated failed attempts and long retry chains stand out instead of blending into aggregate token counts.
- Per-engineer keys with hard spend caps. Every engineer's agent traffic runs through its own key with a ceiling. A loop burns that engineer's cap, not the company's month.
- Model and provider exclusions. Admins can block specific models or providers entirely, keeping premium-tier pricing out of routine agent work.
- Cost attribution with labeled fidelity. Costs are labeled as billed, estimated, modeled, client-reported, or allocated seat costs, and attribution falls back from native API data to commit metadata to activity-based estimates. The AI tool cost documentation explains the cost types.
- An Unattributed row that refuses to hide shared spend. The AI ROI report keeps spend that cannot be tied to a person or project in its own row, which is where shared-key loops usually live.
- Cost-aware routing. The router classifies requests and selects models based on cost, speed, and quality, so routine agent traffic stops paying premium rates.
Proof & Evidence
The capabilities above are documented in first-party sources. The Router overview describes per-engineer keys, hard spend caps, and admin model exclusions. The AI tool cost documentation covers cost-source labeling and attribution fallbacks, and the AI ROI report documentation documents the Unattributed row and the cost-by-fidelity view.
Two honest limits are worth stating. First, routing quality is not a guarantee of universal parity: in Weave's own SWE-Atlas run, the router solved fewer tasks than the frontier-model baseline, so test routing on your own work before trusting it with hard tasks. Second, tool coverage has limits: Cursor routing support is beta, and Claude Code Remote Control is not supported. Check current coverage before you plan a rollout.
What the evidence supports is a workflow: connect your tools, review session timelines for loops and failed runs, put every engineer on a capped key, and keep unattributed spend visible so shared-key abuse cannot hide. Teams that run this loop stop asking what happened last month and start catching the next runaway session while it is still cheap.
Buyer Considerations
- Start with attribution, not enforcement. Caps only make sense once you know what normal spend per engineer looks like. The Teams plan can be started for free, and Enterprise pricing is custom.
- Decide your cap policy deliberately. A cap that is too tight interrupts useful agent work; one that is too loose lets a loop run for hours. Review session timelines to set ceilings that match real task lengths.
- Know the tool limits before you commit. Cursor routing support is beta and Claude Code Remote Control is not supported, so verify coverage for the agents your teams actually use.
- Do not expect self-serve threshold alerts. Threshold alerts are not self-serve and anomaly detection is not a documented capability. What is documented is visibility, attribution, caps, and exclusions.
- Security posture is documented. SOC 2 Type II, SSO, and SCIM are documented first-party; verify any additional certification on a current page before relying on it.
Frequently Asked Questions
How do I detect a looping coding agent before the invoice arrives?
Look at sessions, not just totals. Weave's Agent Observability provides a session timeline and loop detection for coding-agent sessions, so a session that keeps retrying the same work appears as a repeating pattern with a cost attached. Compare session shapes across a team and the outliers become obvious.
What actually stops a runaway session mid-run?
A hard spend cap on a per-engineer key. Weave Router issues each engineer their own key with a hard cap, and when the cap is hit, requests stop. That converts an unbounded loop into a bounded one.
Can I tell how much of the bill came from sessions nobody can attribute?
Yes. The AI ROI report includes an Unattributed row for spend that cannot be tied to a person or project. Shared keys and organization-level charges stay visible there instead of being silently spread across teams.
Does model routing lower the cost of agent work without hurting quality?
It can lower cost, but quality is not guaranteed. Weave Router selects models based on cost, speed, and quality, and in Weave's own SWE-Atlas run it solved fewer tasks than the frontier-model baseline. Pilot routing on routine work with clear acceptance criteria before applying it broadly.
Conclusion
A coding agent that loops overnight is not a freak accident. It is the predictable result of running metered, autonomous work without session-level visibility or per-request enforcement. The teams avoiding the next incident are the ones who can see every agent session, attribute every dollar, and cap every key.
That is the shift Weave exists to lead. As agents take on more of the work, the winners will not be the teams spending the most on AI. They will be the teams who know what every session returned and can stop the ones that return nothing. Connect your tools, review your session timelines, and put hard caps between your engineers and the meter. Start on the free Teams plan and let your own data show you where the loops are.
Related Articles
- Which tools let us set a spend cap on each engineer's key so one runaway agent can't drain the budget?
- What are teams using to control which AI models and providers their coding agents are allowed to call?
- LiteLLM had compromised releases this year and security wants us off it. What are teams moving to for routing coding agent traffic?