Examples
Examples
Small agents that put Riskbound around one sensitive action: refunding an
order through a fake payments API. No real accounts or model keys are
needed. Each one runs the cases from policies/refunds: a $40 refund runs, a
$900 refund is blocked, and a $480 refund waits for a person.
| Example | How Riskbound is added | Language |
|---|---|---|
| typescript-sdk | guard() from the TypeScript SDK | TypeScript |
| python-sdk | guard() from the Python SDK | Python |
| mcp-gateway | The MCP gateway in front of an unchanged MCP tool server | TypeScript |
| openai-agents | guard() inside an OpenAI Agents SDK tool | Python |
| langgraph | guard() inside a LangGraph tool | Python |
| industries | guard() in three support desks: marketplace, food delivery, ride-hailing | TypeScript |
The two framework examples have a scripted mode that needs no model key. The framework still runs the agent loop and calls the tool; only the model's answers are scripted.
Before you start#
You need Node 22 or later, Docker, and for the Python examples uv and Python 3.10 or later. The examples were run with Node 24 and Python 3.14.
Start a local stack from the repo root:
cp .env.example .env
docker compose up -d postgres redis
npm install
npm run db:migrate:dev
npm run db:seed:dev
npm run start:devnpm run db:seed:dev creates a tenant, registers the agent support-bot
with a $2,000 daily cap, makes the refunds policy live, and prints three
keys once:
| Key | Starts with | Used by |
|---|---|---|
| Agent key | rb_agent_ | The SDK examples and the framework examples |
| Admin key | rb_admin_ | Approving the $480 refund, loading policies |
| Gateway key | rb_gateway_ | The MCP gateway example |
The seed script is the way to get keys for now. A /v1/keys route is on
its way, and will be the way to make an agent key without a script.
Keep the keys in your shell for the commands in each example:
export RISKBOUND_AGENT_KEY=rb_agent_... RISKBOUND_ADMIN_KEY=rb_admin_... RISKBOUND_GATEWAY_KEY=rb_gateway_...Approve a refund that waits for a person#
Every example sends the $480 refund only when you set ASK_FOR_APPROVAL=1.
It then waits up to five minutes. Approve it in the dashboard (dashboard/),
or from a second terminal with the admin key:
APPROVAL_ID=$(curl -s http://localhost:8200/v1/approvals \
-H "authorization: Bearer $RISKBOUND_ADMIN_KEY" | jq -r '.[0].id')
curl -s -X POST "http://localhost:8200/v1/approvals/$APPROVAL_ID/resolve" \
-H "authorization: Bearer $RISKBOUND_ADMIN_KEY" -H 'content-type: application/json' \
-d '{"approve": true, "resolved_by": "you@example.com"}'Send "approve": false to reject it. The refund then never runs.
If something looks wrong#
| You see | Why |
|---|---|
blocked (spend_cap) | support-bot has refunded $2,000 today. Each run with an approval adds $520. Run npm run db:seed:dev again for a fresh tenant and keys |
blocked (unknown_agent) | The agent name in the code is not registered for this key's tenant |
blocked (no_matching_policy) | The live policy has no rule for the tool. Load a template from policies/ |
RiskboundUnavailableError | The backend is not running at http://localhost:8200. The action did not run: Riskbound fails closed |
| HTTP 401 | The key is wrong, revoked, or the wrong kind (the gateway needs the gateway key) |
Use another template#
The examples guard refunds because the seed makes that policy live. To guard
another action, load its template (see policies/README.md), then change
the tool name and params in the example to match the template's README.