Skip to content
Docs
Request access

Set a hard budget

A budget is a spending cap that cannot be passed. Before every model call the worst-case cost is reserved; if a budget cannot take it, the call is not made and the task waits for a person. You set budgets in nuramesh.yaml.

What a budget does on every model call Before a model call the worst-case cost is reserved against every budget that applies. If a budget cannot take it, the call is not made and the task waits for a person. Otherwise the call is made and the real cost is settled. Reservethe worst-case cost,before the call Callonly if everybudget can pay Settlethe real cost;release the rest Reservethe worst-case cost,before the call Callonly if everybudget can pay Settlethe real cost;release the rest
A budget is checked before the money is spent. A call that does not fit is never made.
Diagram as text
  1. Before a model call, the worst-case cost is reserved against every budget that applies.
  2. The call is made only if every budget can take the reservation. If one cannot, the call is not made and the task waits for a person.
  3. After the call the real cost is settled and the rest of the reservation is released.
  • A team folder that passes nuramesh validate (Start from a template). The examples use a dev-team folder named my-team.
  • A price for every model the team uses. A call with an unknown price is blocked, never guessed: Override a price.
  1. Open my-team/nuramesh.yaml and find the budgets list. Each budget has an id, a scope, the id of what it caps and a limit.

    budgets:
    - {id: dana-monthly, scope: agent, scope_id: dana, limit: {amount: "5.00", currency: USD}}
    - {id: rhea-monthly, scope: agent, scope_id: rhea, limit: {amount: "5.00", currency: USD}}
    Key Value
    scope run, task, agent, team or org
    scope_id the id of the run, task or agent; for team the id of its lead; for org the organization’s id
    limit an amount and a currency. Write the amount in quotes, as text. USD is the only currency today
    window optional: day or month (UTC calendar). Without it the limit is for the budget’s whole life
    on_breach optional, for a budget with a window: reset or hold at the next window after a breach
  2. Add a cap for the whole organization per day: one new line at the end of the list.

    budgets:
    - {id: dana-monthly, scope: agent, scope_id: dana, limit: {amount: "5.00", currency: USD}}
    - {id: rhea-monthly, scope: agent, scope_id: rhea, limit: {amount: "5.00", currency: USD}}
    - {id: org-daily, scope: org, scope_id: my-team, window: day, limit: {amount: "20.00", currency: USD}}

    scope_id of the org budget is the org.id at the top of the file. Every budget that applies to a call must be able to pay for it: here the developer’s calls count against dana-monthly and org-daily.

  3. Check the file and run the team.

    Terminal window
    nuramesh validate my-team/nuramesh.yaml
    nuramesh try my-team --fake --approve-as human:you --allow-unsandboxed --run-id budget-1

    The fake model costs nothing real, but its calls are priced from the prices section, so budgets behave as they would with a real model.

The report has one line per budget, with what was spent and what is reserved:

Budgets:
dana-monthly (agent dana): spent 0.002670 of 5.00, reserved 0.000000
org-daily (org my-team): spent 0.003471 of 20.00 per day (the current window, since 2026-11-18T00:00:00.000000Z, as of the report), reserved 0.000000

Your amounts and dates will differ. The rb- line is the run budget that the template’s team.py adds for each run.

To see the hard stop itself, add a second, very small budget for the developer and run again with a new run id:

- {id: dana-tight, scope: agent, scope_id: dana, limit: {amount: "0.001", currency: USD}}
Terminal window
nuramesh try my-team --fake --approve-as human:you --allow-unsandboxed --run-id budget-2
BREACH ALERT: hard stop on budget dana-tight (agent dana), limit 0.001; no reset: the lifetime limit is used up (a human can raise it)
Run budget-2
Tasks: 2 cancelled, 1 needs_human
[needs_human] budget-2-fix-add (dana, attempts 1): Fix the failing add() test in calc.py
note: budget hard stop (dana-tight)

The call was never made: the dana-tight line shows spent 0. The tasks that depended on it are cancelled, and the command exits with code 1. This is a demonstration in a throwaway folder: a budget that a run has used stays in the team’s records and still appears in the report after you take its line out of the file.

A budget’s limit, scope, window and on_breach are fixed once a run has used the budget. If you edit them in the file, the next run is refused before it starts:

error: budget 'dana-monthly' already exists with a different limit, scope, window or on_breach than the configuration says; refusing to run with a limit you may not expect

Give the changed budget a new id instead.

You see Do this
validate names a path under $.budgets A key is missing or a value is not allowed. The ids use lower-case letters, digits, - and _
refusing to run with a limit you may not expect You edited a budget that a run already used. Put the old values back and add the new limit under a new id
budget hard stop on the first call The limit is below the worst-case cost of one call. Raise the limit, or make calls smaller: Limit model calls
A call is refused although no budget is used up No budget applies to the call. A call with no applicable budget is refused. Add a budget for the agent, the run or the organization
A call is blocked for an unknown price Set the price: Override a price

Was this page helpful?