Skip to main content

Module cap

Module cap 

Source
Expand description

The spend caps (docs/specs/SPEC_ROUTE_AGENT_BRAKES_2026_11_10.md section 3.2): how much an agent may use through the gateway in a UTC day, and how much a route may. The gateway reads them at each request, so a cap raised mid-turn lets the next request through.

  • Per agent: the agent definition’s content agent:spend_cap_usd. Absent is the app setting model:agent_spend_cap_usd (the default for every agent without a cap of its own), and absent that DEFAULT_AGENT_CAP_USD; none or 0 is no cap.
  • Per route: the app setting model:spend_cap_usd:<route id>. Absent is DEFAULT_ROUTE_CAP_USD; none or 0 is no cap. A route is the OpenRouter route or the Anthropic API-key route (super::catalog::KEY_ROUTE_ID); an agent on a login has plan limits and no cap.

Structs§

Hit
A cap that has been reached.

Enums§

Scope
What a cap was reached for.

Constants§

AGENT_CAP_TYPE
The agent-definition content type the agent’s cap is kept under.
DEFAULT_AGENT_CAP_SETTING
The app setting the default per-agent cap is kept under.
DEFAULT_AGENT_CAP_USD
What an agent without a cap of its own may use in a day when the setting is not set.
DEFAULT_ROUTE_CAP_USD
What a route may be used for in a day when its setting is not set.
MIN_CAP_USD
The least a cap may be set to: a smaller one is not a cap anyone meant.
ROUTE_CAP_SETTING
The prefix of the app setting a route’s cap is kept under; the route id follows.

Functions§

agent_cap
The agent’s cap in dollars a day, or None when it has none.
agent_level
The alert level the agent’s day is at under its own cap; 0 when it has none.
clear_agent_cap
Takes the agent’s own cap away, so it has the default again.
default_agent_cap
The cap an agent has when it has none of its own: the setting, or DEFAULT_AGENT_CAP_USD. None is no cap.
has_own_cap
Whether the agent has a cap of its own (a number or none), and not the default.
level
How far spent is into cap, as the alert level it has passed: 0, 50, 80 or 100.
parse_request
What Agents update spend_cap_usd takes: a positive number of dollars, 0 or "none" for no cap.
reached
The cap the agent’s use today has reached, if any. The agent’s own is checked first.
refusal_text
The refusal the harness shows: what was used, what the cap is and who can lift it.
route_cap
The route’s cap in dollars a day, or None when it has none.
set_agent_cap
Sets the agent’s cap: Some(dollars), or None for no cap.