RiskboundDocs

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.

ExampleHow Riskbound is addedLanguage
typescript-sdkguard() from the TypeScript SDKTypeScript
python-sdkguard() from the Python SDKPython
mcp-gatewayThe MCP gateway in front of an unchanged MCP tool serverTypeScript
openai-agentsguard() inside an OpenAI Agents SDK toolPython
langgraphguard() inside a LangGraph toolPython
industriesguard() in three support desks: marketplace, food delivery, ride-hailingTypeScript

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:

bash
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:dev

npm 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:

KeyStarts withUsed by
Agent keyrb_agent_The SDK examples and the framework examples
Admin keyrb_admin_Approving the $480 refund, loading policies
Gateway keyrb_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:

bash
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:

bash
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 seeWhy
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/
RiskboundUnavailableErrorThe backend is not running at http://localhost:8200. The action did not run: Riskbound fails closed
HTTP 401The 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.