Cap Refunds And Purchases

SDK

Stop 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.

AmountBlock
At or below your cutoffThe tool runs.
Above your cutoffThe tool is denied. The agent gets an error for this call.
No amount on the callThat 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

  1. In the app, open Policies and click Create Policy.
  2. Choose Refund Guard or Purchase Guard. Both say SDK.
  3. Leave Named Tools selected. Type the real function names, such as issue_refund or place_order.
  4. Set Deny Above to your dollar cutoff.
  5. Set the mode to Block, then Activate Policy.
  6. Wrap the agent entry point with govern(), and mark the money function as a tool.

Named Tools

Named Tools is the accurate choice. Only the function names you type are capped. Detect Automatically is the other choice: Traccia looks at the name for words like refund, or buy, purchase, gift, and checkout. A lookup that merely has an amount field is not treated as a refund or a purchase. A function named order, with no purchase verb, is not either.

A Small Agent

Get the API key from app.traccia.ai. The example below is a fake ledger. Traccia does not call Stripe.

refund_desk.py
python
from traccia import init, govern, observe
from 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

Traccia does not move money, call a card network, or undo a refund that already happened. These policies do not apply on the Gateway. They need the SDK and a tool span. Asking a person to approve the middle band is not live yet. If fail_open stays at its default and Traccia cannot be reached, the tool still runs.

Next Steps

© 2026 Traccia.