Skip to content
Docs
Request access

Limit model calls

A model call asks the provider for up to some number of output tokens. A cap lowers that number. You can set a cap on a role, on a task, or both. A cap only ever makes a call smaller. It never raises a request and it never removes a budget check. See Budgets for the spending limits themselves.

Caps are off until you configure one. A call whose role has no max_tokens and whose task has no max_tokens behaves exactly as before, and writes nothing new to the ledger.

Where Key Value
A role in nuramesh.yaml org.roles[].max_tokens a whole number from 1 to 1000000000000
A task Task.max_tokens the same range

0, a negative number, a string, true and a float are all refused. A bad role cap fails nuramesh validate with the path $.org.roles[0].max_tokens. A task is built in code, so an invalid task cap raises a validation error from Task(...). There is no command-line flag, configuration key or API field to set a task cap yet; the task view shows it when one is set.

version: 1
org:
id: my-team
name: My team
roles:
- {id: chief-of-staff, name: Chief of Staff, kind: chief_of_staff}
- {id: writer, name: Writer, default_model: fake/worker-1, max_tokens: 800}
- {id: reviewer, name: Reviewer, kind: verifier, default_model: fake/reviewer-1, max_tokens: 2000}
agents:
- {id: chief-of-staff, name: Chief of Staff, role: chief-of-staff}
- {id: writer, name: Writer, role: writer, reports_to: chief-of-staff}
- {id: reviewer, name: Reviewer, role: reviewer, reports_to: chief-of-staff, checks: [writer]}
policies:
policies:
- role: chief-of-staff
rules:
- {action: delegate, decision: allow, target: "*"}
- role: writer
rules:
- {action: call_model, decision: allow, target: "fake/*"}
- {action: spend, decision: allow}
- role: reviewer
rules:
- {action: call_model, decision: allow, target: "fake/*"}
- {action: spend, decision: allow}
budgets:
- {id: writer-monthly, scope: agent, scope_id: writer, limit: {amount: "5.00", currency: USD}}
prices:
prices:
- {provider: fake, model: worker-1, input_per_million: "3", output_per_million: "15",
effective_from: "2026-01-01T00:00:00Z", source: "example price list (fake model)"}
- {provider: fake, model: reviewer-1, input_per_million: "3", output_per_million: "15",
effective_from: "2026-01-01T00:00:00Z", source: "example price list (fake model)"}
Terminal window
nuramesh validate my-team/nuramesh.yaml

The provider gets the smallest of four numbers, rounded down to whole tokens:

  1. the size the caller asked for,
  2. the role cap,
  3. the task cap,
  4. the most output the tightest applicable budget can pay for, at the versioned price, after paying for the prompt.

If the budget cannot pay for even one output token, the call is the usual budget.exceeded hard stop. It is not made smaller. With no applicable budget there is no budget number, and the usual no_budget refusal applies. A task cap is the worker’s: a verifier call on that task uses the verifier role’s cap, not the task’s.

An unknown price stays blocked. No cap is computed from a missing price, and a role cap does not let a call through that would have been blocked. A call priced by a price override is capped like any other.

Every cut is in the ledger.

Entry When
model.output_capped with stage: applied the call was made smaller; written just before budget.reserved, in the same transaction
model.called with cap_hit: true, then model.output_capped with stage: hit the provider stopped at the cap (finish_reason is length); both are written in one transaction
model.output_capped with stage: not_applied a call that is exempt from caps would have been lowered

The payload names the requested size, the effective size, the role cap, the task cap, the budget cap, which of task, role or budget bound, the limiting budget and its available amount at the time. It holds no prompt or response text. A budget.exceeded refusal that a cap shaped carries details.output_cap with the requested size, the effective size and the binding.

With telemetry on, each entry is counted as nuramesh.model.output_capped with a stage attribute. See Telemetry.

A verifier’s answer that was cut by an applied cap is never a pass. The gate result is error and its message starts with output_capped. A cut at the gate’s own max_output_tokens, with no cap applied, is unchanged.

Calibration and evaluation runs are never capped, so the output sizes they measure stay valid. If a role cap would have lowered such a call, the ledger records stage: not_applied. A calibrated gate whose verifier role cap is below the suite max_output_tokens is refused with verifier role max_tokens below the suite max_output_tokens.

NuraMeshChatModel.max_output_tokens is still the size you ask for. The AIMessage.response_metadata it returns has finish_reason, nuramesh_max_output_tokens (the size the provider got) and nuramesh_cap_hit.

  • No app screen shows or edits a cap.
  • No way to set a task cap from the command line, the configuration file or the API.
You see Do this
validate names $.org.roles[0].max_tokens The cap is not a whole number from 1 to 1000000000000. 0, a negative number, a string, true and a float are refused
budget.exceeded although a cap is set The budget cannot pay for even one output token. A cap makes a call smaller; it never removes a budget check
An answer is cut short The provider stopped at the cap: the ledger has model.called with cap_hit: true. Raise the cap or ask for less
A call is still blocked for an unknown price A cap does not let such a call through. Set the price

Was this page helpful?