Onboarding guide
7. Going to production
Read this page together, lead and engineer, before real traffic goes through Riskbound.
Fail closed: what happens when Riskbound cannot be reached#
By default, if the SDK or the gateway cannot get a clear answer from Riskbound, the action does not run. This is called failing closed.
"Cannot be reached" means: no connection, no answer within the timeout, or
a 5xx error from Riskbound. In those cases:
- the SDK throws
RiskboundUnavailableError, and your action is not called; - the gateway returns an error result to the agent, and the tool is not called.
Plan for it. Decide what your agent should do when it gets this error: tell the user to try later, queue the work, or hand it to a person.
TypeScript:
import { createRiskbound, RiskboundUnavailableError } from "@riskbound/sdk";
const riskbound = createRiskbound({
apiKey: process.env.RISKBOUND_API_KEY!,
baseUrl: process.env.RISKBOUND_URL ?? "http://localhost:8200",
timeoutMs: 3000,
onError: (err) => console.error("riskbound:", err),
});
const refund = riskbound.guard("refund", { agent: "support-bot" });
try {
await refund({ order_id: "ord_1004", amount_minor: 4_000, currency: "USD" }, () => "refunded");
} catch (err) {
if (err instanceof RiskboundUnavailableError) {
console.log("Not refunded. Riskbound could not be reached:", err.message);
} else {
throw err;
}
}Python:
import os
from riskbound import Riskbound, RiskboundUnavailableError
rb = Riskbound(
api_key=os.environ["RISKBOUND_API_KEY"],
base_url=os.environ["RISKBOUND_URL"],
timeout=3.0,
approval_poll_interval=2.0,
approval_timeout=900.0,
on_error=lambda err: print("riskbound:", err),
)
refund = rb.guard("refund", agent="support-bot")
try:
refund({"order_id": "ord_2005", "amount_minor": 4_000, "currency": "USD"}, lambda: "refunded")
except RiskboundUnavailableError as err:
print("Not refunded. Riskbound could not be reached:", err)With Riskbound stopped, both print a line that starts with
Not refunded. Riskbound could not be reached.
Fail open, and why we advise against it#
You can set one guard to fail open: failMode: "open" (TypeScript),
fail_mode="open" (Python) or "failMode": "open" in the gateway's
riskbound block. Then, if Riskbound cannot be reached, the action runs
unchecked and the result says outcome: "fail_open".
Know what that costs:
- No rules, no limits and no record. A fail-open action has no decision id and is not in the evidence log.
- It only applies when Riskbound cannot be reached. A rejected request, such as a bad or revoked key, never fails open.
- Once a person has been asked to approve, it never fails open.
Use it, if at all, only for low-risk actions where stopping costs more than an unchecked run. Never for money.
Timeouts#
| Setting | Default | TypeScript | Python | Gateway (riskbound block) |
|---|---|---|---|---|
| Wait for each answer from Riskbound | 3 seconds | timeoutMs | timeout | timeoutMs |
| How often to check an approval | 2 seconds | approval.pollIntervalMs | approval_poll_interval | approvalPollMs |
| Stop waiting for a person | 15 minutes | approval.timeoutMs | approval_timeout | approvalTimeoutMs |
Python takes seconds. TypeScript and the gateway take milliseconds.
On our side, an approval nobody answers expires after 15 minutes. Keep your approval wait at or below that. If your agent serves a person who is waiting, a shorter approval wait may suit them better. The action still does not run when the wait ends.
Speed. Each check is one round trip to Riskbound, and an allowed action
also sends one short report after it runs. On a laptop against a local
Riskbound, the gateway's check added about 5 ms per call. That is a local
measurement, not a production number: in production, add the network
distance between your systems and ours. Measure on your own setup. To skip
waiting for the report, set reportResult: "background" (TypeScript) or
report_result="background" (Python). The gateway already does this.
Retries#
idempotencyKey (TypeScript) or idempotency_key= (Python) on a call
sends a key with the request. If the same key is sent again, Riskbound
returns the first decision instead of making a new one. That keeps the
log and the daily spend count from counting a retry twice.
It does not stop your action from running twice. If the first answer
was allow, a retry with the same key runs the action again. Make the
action itself safe to repeat, for example by passing the same key to your
payments API.
Stop buttons#
Make sure whoever is on call knows these. Each one takes effect on the very next request, and each one is recorded with who did it.
| Control | Effect | Undo |
|---|---|---|
| Pause one agent | Every action by that agent is blocked with agent_paused | Resume |
| Kill one agent | Every action by that agent is blocked with agent_killed | None. Register a new agent |
| Kill switch | Every action by every agent in your account is blocked with kill_switch | Release the kill switch |
In the dashboard: Agents has Pause, Resume and Kill for each agent. Overview has Stop all agents and Release kill switch.
With the API:
# Pause one agent. Use "active" to resume, "killed" to kill.
curl -s -X POST "$RISKBOUND_URL/v1/agents/support-bot/status" \
-H "Authorization: Bearer $RISKBOUND_ADMIN_KEY" \
-H "Content-Type: application/json" \
-d '{"status": "paused", "actor": "Your name"}'# Stop every agent.
curl -s -X POST "$RISKBOUND_URL/v1/kill-switch" \
-H "Authorization: Bearer $RISKBOUND_ADMIN_KEY" \
-H "Content-Type: application/json" \
-d '{"on": true, "actor": "Your name", "reason": "Refunds look wrong"}'# Release it.
curl -s -X POST "$RISKBOUND_URL/v1/kill-switch" \
-H "Authorization: Bearer $RISKBOUND_ADMIN_KEY" \
-H "Content-Type: application/json" \
-d '{"on": false, "actor": "Your name"}'Practise once before go-live: pause the agent, watch a request get blocked, then resume it.
Keys#
Your API keys. Keep the agent key in the agent's secret store and the
admin key with people, never in agent code. Make, list and revoke keys on
the dashboard's Keys page, or with POST /v1/keys, GET /v1/keys and
POST /v1/keys/<id>/revoke. Each change is in the evidence log. With single
sign-on Enterprise, when your organisation requires it, only a person
signed in with SSO can make keys.
The list shows when each key was last used, so unused keys are easy to
spot. To rotate a key:
- Make a new key.
- Deploy it to the agent or the gateway.
- Revoke the old one.
A revoked key is refused at once with 401. The SDK treats that as a
rejected request, which never fails open. A gateway serving HTTP drops
sessions of a revoked key within a minute.
Our signing key. We may change the key that signs your evidence. Old events stay checkable, because every public key that ever signed is kept. When it happens, we send you the new public key. Anyone checking an export then passes both keys to the verify script (page 6).
What to watch#
| Where | What to look for |
|---|---|
| Approvals and Overview | Requests waiting a long time. Expired approvals are refusals your users felt |
Decisions, filtered to block | Reasons you did not expect. Many rate_limited or spend_cap may mean limits are too tight, or the agent is looping |
| Watch and Watch / agent | Each agent's tools, outcomes and risk score. Save scores now and then to see the trend |
| Failures | Everything that did not end well, grouped by cause: blocks, rejections, expired approvals, and actions that ran but failed |
| Evidence | The full check should stay OK. If it is not, tell us at once |
| Your own logs | RiskboundUnavailableError counts, and anything sent to onError / on_error, such as a failed result report |
| Gateway logs | The gateway logs to stderr, for example Riskbound unreachable, call refused |
Before go-live checklist#
- Policy is live, and you tried each rule with Check this request
or
POST /v1/policies/simulate. - The agent's limits (daily spend cap, rate) are set.
- The agent has an agent key. The admin key is not in agent code.
- Your code handles
RiskboundBlockedErrorandRiskboundUnavailableError. - Fail closed (the default) for every money action.
- Approvers are named, and know where requests show up.
- With the gateway: the tool credentials are only in the gateway.
- On call knows how to pause the agent and pull the kill switch, and has tried it.
- Params carry no personal data you do not need.
- Someone has run the verify script on an export once.
Next: 8. Glossary and FAQ.