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

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.