Patterns / Cost guard
Agent cost guard: estimates, budgets and spend
Agent runs cost money, and people should see how much before they say yes. RunEstimate shows the likely cost and time as ranges, with what they're based on. Without enough history it says there's no estimate rather than guessing.
After a run, RunReceipt says what it cost, per model. A cost that wasn't measured says so; it's never shown as $0.00. UsageMeters shows what's used against each limit, and SpendBreakdown shows spend over time by model, agent or feature.
When a guardrail stops a run, GuardrailNotice says what was stopped and which rule stopped it.
The components
- Run estimateProLikely cost and time, as ranges, before a run starts.
- Run receiptProWhat one run cost and where it went.
- Usage metersProWhat's used against each limit; no bar against a made-up cap.
- Spend breakdownProSpend over time, by model, agent or feature.
- Guardrail noticeProWhat a budget stopped, and why.
- Context meterFreeWhat fills the model's context budget, in the composer.
See it working
More in the examples: Run estimate and log
Install
With the shadcn CLI
Each component brings in what it depends on. The free ones install as they are; Pro and Premium ones need a licence key.
Good to know
- The cost-guard block (Premium) enforces it: the agent estimates from recorded runs or says it can't, the person approves a budget, and the run stops on the server when recorded spend reaches it.