Examples
Python SDK example
A support agent that refunds orders through a fake payments API
(payments.py). Every refund goes through guard() from the Python SDK
first (agent.py).
Run it#
Start the local stack and get an agent key first: see ../README.md. Then:
cd examples/python-sdk
uv venv .venv
uv pip install -p .venv -r requirements.txt
RISKBOUND_API_KEY=$RISKBOUND_AGENT_KEY .venv/bin/python agent.pyYou see:
[payments] refunded 40.00 USD on ord_1001
40.00 USD on ord_1001: allow, refund re_0001
900.00 USD on ord_1002: blocked (refund-hard-cap)
Refunds issued: 1To see a refund wait for a person, run this and approve it as
../README.md shows:
ASK_FOR_APPROVAL=1 RISKBOUND_API_KEY=$RISKBOUND_AGENT_KEY .venv/bin/python agent.pyWithout uv: python3 -m venv .venv && .venv/bin/pip install -r requirements.txt.
What to copy into your own agent#
rb = Riskbound(api_key=api_key, base_url=base_url)
guarded_refund = rb.guard("refund", agent="support-bot")
guarded_refund(
{"order_id": order_id, "amount_minor": amount_minor, "currency": "USD"},
lambda: payments.refund(order_id, amount_minor, "USD"),
)For asyncio code, use AsyncRiskbound, as ../openai-agents does.