Agent in Production
ResilienceLong read

How Hard Spending Limits Either Halt Autonomous Coding Sessions or Just Log Them

Only limits that block the next call actually stop runaway agents.

· 8 min read
Cover illustration for “How Hard Spending Limits Either Halt Autonomous Coding Sessions or Just Log Them”
Resilience · December 1, 2026 · 8 min read · 1,898 words

Hard spending limits stop autonomous coding costs only when they block the next chargeable call, while recording spending after it happens provides passive logging. Effective enforcement combines a pre-call budget check with task-level limits, retry thresholds, and scoped permissions. For work that cannot safely stop mid-task, the alternative to passive logging is a state-preserving pause with human approval.

Why autonomous coding agents run up bills nobody planned for

Autonomous coding agents can fail financially without crashing. A stuck task can keep retrying the same operation, making another plausible tool call each time without getting closer to finishing. Each retry consumes resources, but successful execution of the call does not establish progress on the task. Without a failure threshold, the system has no enforced reason to stop. Continuing becomes the failure.

Context overhead compounds the cost of that persistence. Repository maps, system prompts, and prior tool outputs account for the largest share of token consumption in a real session. An agent that reads full context each time therefore pays for all its history as well as its next attempt. Benchmark cost-per-task figures understate that burden. Many tools also lack a default cap, leaving teams to opt into protection before an unattended run exposes the omission.

The real-world reckoning that made enforcement a priority in 2026

The enterprise reckoning in 2026 exposed a weakness in the monthly-budget approach. Having a monthly cap did not necessarily prevent an individual run from consuming an unacceptable share of it. A monthly allowance describes how much an organization permits over a billing period, while the immediate problem is a task that keeps spending without making progress. Those are different conditions, and they need different triggers.

Lowering the monthly number is a natural response because it reduces the amount available to lose. It does not diagnose the run. The same retry loop can exhaust a smaller allowance before anyone intervenes, potentially consuming budget intended for useful work. Spending controls therefore need to be evaluated by the event that activates them and what happens next. A control that responds to how much has already been spent may come too late to stop the behavior behind the spending.

What "spending limit" actually means depends entirely on when it fires

Diagram: Three Spending Control Modes: What Each One Actually Does. Visualizes: Show three distinct operating modes for spending limits as a visual taxonomy with outcomes.

A hard stop prevents the run from proceeding to the next chargeable call. A soft pause interrupts the run, alerts a human, and preserves session state pending a decision. A passive log records consumption without changing execution. These are three different operating modes. Only the first two intervene in the run.

For a limit to be hard, every charged call must pass through a mandatory budget check, with the check and decrement performed as one atomic operation before dispatch. Relying on the agent to consult a separate budget tool voluntarily makes compliance optional. Callbacks, traces, and usage dashboards remain useful, but an overnight loop can fill them with accurate records while continuing to spend.

Even an enforced approval needs a reliable measurement boundary. An agent's declared task budget is an estimate because retries, token overage, and long-running metered calls can push the final cost beyond it. Local checks can pass even when the estimate turns out to be too low. Chargeable execution therefore requires a gate. A graceful pause adds a human decision at that gate.

How major platforms actually behave when a limit is reached

OpenAI rolled out hard spend limits for organizations and projects across API Platform accounts in the week of 22 July 2026. Affected requests return a blocking 429 response once the limit is reached. OpenAI's documentation nevertheless acknowledges that enforcement is not instantaneous and recorded spending can slightly exceed the configured amount while the limit propagates. A genuine hard limit can therefore still have enforcement lag.

AWS introduced spending limits on 16 September 2026 as part of a new sign-up experience. The monthly limit starts at a low default and can pause the project and stop its resources when reached. The limit still applies to the project for the month, so it does not protect each task from calls that keep failing.

Microsoft Azure budgets illustrate the opposite behavior. Microsoft's documentation states that budget thresholds trigger notifications, while resources are unaffected and consumption does not stop. Separate automation is required to enforce a shutdown. The notification can support an operating procedure, but it cannot substitute for one.

Cognition is adding hierarchical budgets to Devin that extend up to three levels through the organization chart. Under that model, budget exhaustion stops the session, alerts engineers, and lets them request more Agent Compute Units within the workflow. The interruption is explicit. Cognition is also working on switching to lower-cost models after a soft limit, creating a possible continuation path.

Cloudflare AI Gateway places enforcement outside the model layer. Its spend-limit documentation describes a default blocking mode that rejects requests until the budget window resets, as well as a fallback mode that routes requests to a cheaper model. The gateway provides an architectural contrast to billing notifications because it sits in the request path. That position is useful across providers, provided all relevant traffic passes through it. It does not, on its own, address session credential scoping or the full audit requirement.

Why monthly caps set at the wrong layer miss the actual failure mode

Diagram: Four Run-Level Circuit Breakers. Visualizes: Illustrate four distinct run-level controls that apply circuit-breaker logic during a task, not at the monthly billing layer.

A circuit breaker responds to failures while a system is running. Michael Nygard popularized the software resilience pattern of cutting off a service once failures pass a threshold, rather than allowing callers to keep retrying into it. An autonomous agent needs the same interruption logic. A monthly budget can eventually halt expenditure, but until that boundary is reached, it does not distinguish a productive task from a loop.

Four controls apply that logic at the run level. An iteration limit caps steps or tool calls before the next step executes, regardless of apparent progress. A per-task dollar or token budget uses an atomic check before each step to cap how much the task can use. Failure thresholds trip when errors occur in a row, calls are retried, or confidence falls below a set floor. Scope enforcement then bounds what the agent can affect.

These controls address different failure conditions. A task can stay within its token allowance while failing over and over, or finish in few steps while going beyond its intended permissions. No single monthly counter captures those distinctions. LangGraph and similar frameworks expose a recursion_limit, but a permissive setting can allow many LLM calls before a bad workflow exhausts it. Breakers should be configured around task behavior, with the monthly cap serving as a broader financial backstop.

The case for soft stops — and where they cannot substitute for a hard one

A hard cutoff is not always the safest outcome. In customer-facing or high-stakes production workflows, interrupting useful work mid-task can create a user-facing failure or leave an operation incomplete. Production practitioners therefore have a legitimate objection to indiscriminate shutdowns. A human handoff costs labor, but it can preserve continuity without allowing the agent to continue unattended. The appropriate boundary depends on the cost of interruption as well as the cost of continuation.

A soft pause answers that objection only if it actually pauses. It preserves state and requires a decision before work resumes, rather than sending a warning while the same run keeps spending. Graduated responses can also preserve useful work. Cognition's proposed lower-cost-model path illustrates that approach, although cheaper continuation is distinct from a pause and still needs a financial boundary.

For unattended overnight batch work and CI-triggered agents, a hard stop keeps the cost failure from going on while no one is watching. For interactive customer-facing sessions, a soft pause with human approval is preferable. Scoped permissions support recovery by limiting what an interrupted run could have changed. Without those boundaries, stopping may be the only protection against an irreversible action.

What governance infrastructure needs to exist around the limits themselves

A limit needs an identity against which to enforce it. Shared API keys prevent reliable attribution of expenditure to individual developers or agents, undermining controls intended to apply separately to each. Session-scoped credentials establish that boundary. They are minted for a run, limited to its needs, and revoked when it ends, so chargeable activity belongs to a known execution context.

Attribution must also explain the work behind the bill. Useful records capture the user, team, agent version, model, task type, environment, and timestamp. Otherwise, a monthly total cannot distinguish successful automation from thousands of inefficient loops. Budget is not authorization, either. Changes to production infrastructure, external communications, and access to sensitive data should need explicit human approval, no matter how much money is left.

Policy-as-code connects these requirements in a reviewable form. Version-controlled configuration defines budget boundaries, approval thresholds, credential scope, and retry limits rather than leaving them in a dashboard visible to one operator. Recording tool calls, diffs, and policy outcomes supports forensic analysis and compliance needs that billing records alone cannot meet.

Ellipsis is one implementation of this pattern, with repository-based YAML agent definitions, isolated session sandboxes, session-scoped credentials, and hard session and developer budget caps that block further chargeable calls. It logs tool calls, diffs, and thinking tokens with attribution to a person or trigger, providing a concrete option for evaluating managed execution and governance together.

How to evaluate whether a platform's limits actually halt or just log

An engineering team should start with the session-level model described above and ask four questions of every alternative. Does crossing the limit return an error to the caller, or only notify a human? Is the check atomic with the chargeable call, or evaluated asynchronously from usage data? Does it apply per session and task, or only to a monthly organization total? Are credentials scoped and revoked per session, or shared across runs?

A gateway such as Cloudflare's can block the request before it reaches the model, provided traffic cannot bypass it. Devin's described budget model acts on the session itself. OpenAI's hard limits and AWS's spending limits provide genuine blocking behavior, but at broader monthly scopes. Azure budgets belong in the notification category unless separate automation supplies the missing enforcement.

For other candidates, the same questions are more useful than assumptions based on their names. Teams looking at LiteLLM, Portkey, or Bifrost need to check whether the configuration they choose gates requests before dispatch and how it counts concurrent or in-flight spending. For Claude Agent SDK, Claude Managed Agents, and Amazon Bedrock AgentCore, the evaluation needs to distinguish runtime interruption from usage reporting. AgentBudget and Helicone likewise require evidence of the configured enforcement behavior before being treated as hard-stop controls. A product's inclusion in a budget discussion does not establish its shutdown semantics.

Graceful shutdown deserves its own acceptance criteria. Teams should establish whether a threshold preserves session state, returns a partial result, cancels subagents, or produces a structured budget error, rather than assuming those behaviors follow from a blocked request. Enforcement lag needs equal attention. A rejected next call does not by itself explain how already-dispatched work is accounted for, and delayed billing data can weaken an otherwise clear boundary.

The recommended setup combines a mandatory pre-call gate with per-task budgets, iteration and failure thresholds, scoped credentials, and a monthly backstop. Human approval lets work resume when an abrupt halt would pose a greater risk to operations. Audit records then explain what happened without being mistaken for the mechanism that stopped it.

Filed underResilience

More in Resilience