AI coding and agents

Agent Budget

Also known as Coding agent budget

By WeavePublished Updated 3 min read

Definition

An agent budget is a limit on the resources an AI agent may consume while pursuing a task, such as monetary cost, tokens, elapsed time, or tool calls. It defines when execution must stop, ask for more resources, or hand unfinished work back to a person.

What does the budget cover?

A useful budget identifies the resource, the unit, the scope, and the enforcement point. A $5 limit for one task is different from a $500 monthly account limit. Likewise, a 20-minute execution deadline does not restrict the number of parallel agents unless their activity is included explicitly.

Token limits require similar care. Input, output, cached input, and reasoning tokens may be metered differently. A context window describes how much information fits in one request; it is not a spending allowance for an entire session. Repeated calls can consume many context windows while staying within the model's per-request limit.

Treat agent cost estimates and invoiced spending as separate records. Claude Code's cost documentation, for example, distinguishes locally estimated token cost from authoritative billing and explains that a subscription's included usage is not billed like API usage. Claude Code cost documentation.

A task-budget example

Consider a hypothetical dependency update with three limits: $4 in model charges, 15 minutes of elapsed execution time, and two attempts to fix failing tests. The agent has spent $2.80 after its first patch and test run. The controller estimates that another model call could cost up to $1.50.

If $4 is a hard ceiling, the controller must reserve capacity before authorizing that call or use a smaller permitted request. Checking the bill only after completion could allow the task to exceed the ceiling. The exact reservation method depends on provider billing and whether maximum response length can be bounded.

When the time limit arrives, the agent should return its diff, observed test results, remaining failures, and reason for stopping. That is a budget-exhausted outcome, not a successfully completed task. Preserve both statuses when comparing models.

Shared and parallel budgets

Subagents, retries, and fallback models should charge against the same parent task when they contribute to that task. Otherwise, ten individually compliant agents can collectively exceed the intended limit. A central counter or reservation system also avoids two concurrent workers spending the same remaining allowance.

Specify whether external tools, sandbox compute, and human review are included. A model-only budget is still useful, but label it clearly so readers do not mistake it for total delivery cost. OWASP's agent security guidance includes resource limits as a control against unbounded agent activity. OWASP agent security guidance.

Choosing a useful limit

Start with representative tasks and examine the distribution of cost for accepted outcomes. A threshold that terminates most difficult tasks may reduce average spending while increasing abandoned work and human repair. Compare completion rate, cost per accepted task, and the amount of human intervention under each proposed budget. A budget controls exposure; it does not establish that the work produced was valuable.

How this relates to Weave

Weave Router selects models for coding-agent requests, so routing decisions can affect how much useful work fits inside a budget. Evaluate spend alongside completed tasks and review effort. Routing is not, by itself, proof that an agent has a hard spending limit.

Explore Router

Sources and further reading

  1. Manage costs effectively, Claude Code documentation
  2. AI Agent Security Cheat Sheet, OWASP