Cap Refunds And Purchases
SDKStop an agent from refunding or buying above a dollar amount you set, before that function runs.
A support agent can call issue_refund. A storefront agent can call place_order. The model fills in the amount. Refund Guard and Purchase Guard stop that function when the amount is above the cutoff you set. The function body does not run.
This is not your LLM bill. Spend Cap limits what the model call costs. These two policies limit money the agent tries to move through a tool.
What You Are Protecting
Refund Guard
A billing agent credits a customer. You allow refunds at or below $50. An $80 refund is denied. The ledger function never runs.
Purchase Guard
A checkout agent places an order. You set your own cutoff, for example $25. An $80 gift card is denied. A $18 mug still goes through.
| Amount | Block |
|---|---|
| At or below your cutoff | The tool runs. |
| Above your cutoff | The tool is denied. The agent gets an error for this call. |
| No amount on the call | That rule is skipped. The tool still runs, and the match is a warning. |
Observe logs the match and lets the tool run. Warn does the same and records Would-Have. Only Block denies the call. The trace is still accepted.
Turn It On
- In the app, open Policies and click Create Policy.
- Choose Refund Guard or Purchase Guard. Both say SDK.
- Leave Named Tools selected. Type the real function names, such as
issue_refundorplace_order. - Set Deny Above to your dollar cutoff.
- Set the mode to Block, then Activate Policy.
- Wrap the agent entry point with
govern(), and mark the money function as a tool.
Named Tools
A Small Agent
Get the API key from app.traccia.ai. The example below is a fake ledger. Traccia does not call Stripe.
from traccia import init, govern, observefrom traccia.governance import AgentBlockedError
init( api_key="...", endpoint="https://api.traccia.ai/v2/traces", agent_id="refund-desk",)
@observe(name="issue_refund", as_type="tool")def issue_refund(order_id: str, amount: float) -> dict: return {"ok": True, "order_id": order_id, "amount": amount}
@govern(fail_open=False, name="refund_desk")def handle_ticket(order_id: str, amount: float) -> dict: return issue_refund(order_id, amount)
try: handle_ticket("ORD-1042", 80)except AgentBlockedError as exc: print(exc)With Refund Guard at $50 and Block on, 80 is denied and 20 runs. Purchase Guard is the same pattern on place_order, with its own cutoff.
What This Does Not Do
fail_open stays at its default and Traccia cannot be reached, the tool still runs.Next Steps
© 2026 Traccia.