Riskbound SDK (Python)
The Python SDK. It asks Riskbound before an AI agent acts, then carries out
the answer. It matches the TypeScript SDK in ../sdk in behaviour and on the
wire. It has no runtime dependencies, needs Python 3.10 or later, and is not
published yet.
import os
from riskbound import Riskbound, RiskboundBlockedError
rb = Riskbound(api_key=os.environ["RISKBOUND_API_KEY"], base_url="http://localhost:8200")
refund = rb.guard("refund", agent="support-bot")
try:
result = refund(
{"order_id": "ord_2291", "amount_minor": 48000, "currency": "USD"},
lambda: payments.refund("ord_2291", 48000),
)
# result.outcome is "allow" or "ask_human"; result.value is what the action returned.
except RiskboundBlockedError as err:
# err.reasons says why: a policy id, "spend_cap", "kill_switch", ...
...
For asyncio code, use AsyncRiskbound. Actions may be async or plain
functions. HTTP runs in a worker thread, so the event loop is not blocked.
from riskbound import AsyncRiskbound
rb = AsyncRiskbound(api_key=..., base_url=...)
refund = rb.guard("refund", agent="support-bot")
result = await refund({"amount_minor": 48000, "currency": "USD"}, do_refund_async)
What happens for each outcome
| Outcome | What the SDK does |
|---|---|
allow |
Runs the action and reports the result |
ask_human |
Waits for a person, polling every approval_poll_interval seconds. Runs on approval; raises RiskboundBlockedError on rejection or expiry, RiskboundApprovalTimeoutError after approval_timeout seconds |
dry_run |
Runs the dry_run= handler you passed, never the real action. Without a handler, policy never offers a dry run, and if it does anyway the call is blocked |
block |
Raises RiskboundBlockedError. The action does not run |
When Riskbound cannot be reached
By default the guard fails closed: it raises RiskboundUnavailableError and
the action does not run. That covers no connection, a timeout (timeout=,
3 seconds by default) and any 5xx answer. Pass fail_mode="open" to a guard
to run the action unchecked instead; the result says outcome="fail_open"
and the error goes to on_error. Fail-open never applies to a rejected
request (4xx, RiskboundRequestError), and never once a person has been asked.
Reporting the result
After the action runs, the SDK tells Riskbound whether it worked. A raised
exception is reported as failed, with its message, and raised again
unchanged. By default the guard waits for the report. Pass
report_result="background" to send it after: on a daemon thread for
Riskbound, as a task for AsyncRiskbound (call await rb.drain() before the
program exits). A failed report goes to on_error and never changes the
result.
Other options
idempotency_key=on a call: send the same key again to get the same answer instead of a new decision.- Requests carry
via: "sdk", which the risk score uses (../docs/adr/0010-risk-score.md). transport=,sleep=andclock=are for tests.
Amounts
Send amounts as whole numbers in minor units (amount_minor: 48000 for
$480.00). Floats are rejected by the backend.
Develop
uv venv .venv && uv pip install -e '.[dev]'
.venv/bin/ruff check . && .venv/bin/ruff format --check . && .venv/bin/mypy && .venv/bin/pytest
Tests run the SDK against a stand-in Riskbound API on a real local HTTP
server (tests/fake_server.py), so the real transport is used.
Metadata
Release files for riskbound 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| riskbound-0.3.0.tar.gz | 17.2 kB | With provenance | Details for riskbound-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| riskbound-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for riskbound-0.3.0-py3-none-any.whl |
Total release size: 31.5 kB
Release files / riskbound-0.3.0.tar.gz
| Download URL | riskbound-0.3.0.tar.gz |
|---|---|
| Size | 17.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a0b5a4ba150dd224e102435c1a31d94448eaa5aae58b5a3a7f6e9eb304413faa
|
|
BLAKE2b-256 checksum How to use checksums |
3ca4fad56e29e3b6439274d2a9779b6bb08b5bd4f734c9ffa2d1288dbccdc8d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.
Transparency logRelease files / riskbound-0.3.0-py3-none-any.whl
| Download URL | riskbound-0.3.0-py3-none-any.whl |
|---|---|
| Size | 14.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f0a5374e98ac0e5af69c7f9c73aa27ccc095e57d44b0417dd6929dfdc2b997ed
|
|
BLAKE2b-256 checksum How to use checksums |
1381bc98b0b83e0c5abd9d36b97ce279c5fe2d73967e753ffde1570f278b66b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.
Transparency logSecurity for riskbound 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for riskbound-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.