Cap Refunds And Purchases

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. Ask For Approval is optional and off by default. When you turn it on, a middle band waits for a person. Approve A Refund Or Purchase.

What You Set

Name the tools, choose Currency, and set the cutoff in that currency. Named Tools is recommended. The agent must send the amount on the tool arguments. A bare number uses the policy currency. If the amount is missing, the rule is skipped and the tool still runs. With Ask For Approval off, a currency code on the call is not a separate deny. At or below the cutoff, the tool runs. Above it, Block denies the tool.

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. Choose Currency. USD is the default. The cutoff is in that currency.
  5. Set Deny Above to your cutoff.
  6. Set the mode to Block, then Activate Policy.
  7. 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(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. The TypeScript example passes one arguments object so Amount Path amount reads the named amount field.

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. Ask For Approval is optional on these two policies. See Approve A Refund Or Purchase. If Traccia cannot be reached, the tool follows your setting under Settings → Policy Enforcement, which blocks by default, from Python SDK 0.1.34 or TypeScript SDK 0.1.20. Older SDKs let the tool run.

Next Steps

© 2026 Traccia.