Skip to main content

Module budget

Module budget 

Source
Expand description

Task 23 — per-turn budgets (spec §8.1).

Every stream session runs under one TurnBudget: provider rounds, tool calls, elapsed wall-clock, accumulated tool-result bytes, and the optional context-token / USD-cost dimensions. Budgets differ by role (foreground, autonomous/watcher, worker) but share ONE enforcement mechanism — the TurnBudgetMeter consulted by the stream loop.

Composition note: the chat frontend’s reactor auto-turn cap (engine::reactor::AUTO_TURN_CAP) limits consecutive auto-triggered turns ACROSS turns; this budget bounds work WITHIN one turn. They compose — neither replaces nor duplicates the other.

Structs§

TurnBudget
Per-turn limits (spec §8.1).
TurnBudgetMeter
One turn’s running budget meter. NOT thread-shared: owned by the stream loop; the only cross-task input is the UsageCounters cell.
UsageCounters
Shared provider-usage counters, updated at the single authoritative Usage emission sites in the transport and read by the stream loop for the optional token/cost dimensions. Metadata only.

Enums§

TurnRole
Execution role a turn runs under.