Write the envelope, run a real agent inside it, read what it cost. The caps are enforced by the production gateway, and the receipt is the gateway's own document.
Two actors. The agent is the workload: in production your code, here our fixed toy. The gateway is the enforcement layer underneath it. The spec is the contract between them, and it is what meters the work.
Three ways to narrow the envelope. Each one edits a line below, and the gateway enforces it.
| Knob | What it governs | Status |
|---|---|---|
steps.*.model_tier | which tier serves a phase: a tier, never a model. Substitution inside the tier is ours | live here |
steps.*.max_iterations | turns per phase, the loop bound behind the static worst case | live here |
steps.*.max_output_tokens | output cap per call. Tighten it and watch the computed worst case, and the price, drop | live here |
tools.*.tool_budget_tokens | size of each tool result fed back to the agent | live here |
tools.*.max_calls | total tool calls per unit. Past it the gateway returns a budget-exhausted notice instead of results and tells the agent to answer from what it has | live here |
unit_ceiling_usd | a hard dollar stop per unit, below the computed bound | live here |
steps.*.last_turn_warning | whether the gateway warns the agent before the cap. Set it false and watch resolution rates fall | live here |
terminal | the allowed end states, and a unit must close as one of them. The gateway refuses a close in any state your spec does not declare. This toy reaches resolved and escalated, and closes ceiling_exceeded when the gateway stops it and your spec declares that state | live here |
routing_constraints | data residency and provider allow or deny lists that substitution must respect | accepted, not yet enforced |
Unknown keys are rejected with the allowed grammar echoed back. Every knob that narrows the envelope lowers the computed worst case, the ceiling the gateway enforces, and the number a quote is written against. A tighter spec buys a better price.
One fixed price covers a whole queue of these. Write your own and watch the same price meet a very different bill.
Nothing spent yet. Run the agent and this fills with the real calls, one segment each, priced at the moment they were made. If a cap binds, the run stops here and the signal that stopped it is spelled out underneath.
Try it, then try breaking it. Out-of-range and unknown keys are refused, not quietly rewritten, and the message you get back is the production grammar's own.
Here the agent self-reports resolved by declaring its answer final, and this route closes the unit with it. In production, terminal states are closed by your system (sm.close(unit, state)), not asserted by the model. Auditing that gap is part of the contract design.
The toy agent searches a 12-topic policy knowledge base (refunds, shipping, warranty, billing, account). A search that misses returns the list of covered topics, so the agent knows what it can and cannot answer.