This release is a pre-release and may not be stable for production use.
boundri-sdk
Your enterprise customers decide what your agent may do, with their own limits and approvers. This SDK asks Boundri before each tool call runs and hands your code the answer: allow, deny or wait for approval. Each customer's rules apply without a release on your side.
Apache-2.0 Python SDK for Boundri. It evaluates a compiled policy bundle where
the agent runs — locally against an embedded OPA (LocalEvaluator) or against
the hosted POST /v1/evaluate (RemoteEvaluator) — and hands the decision to
a framework adapter or to your own code.
It never compiles policy: compilation goes through the hosted compiler
(POST /v1/compile). This package holds no credentials for your tools and
dispatches no calls; it answers whether a call may proceed.
pip install -e packages/sdk-python/
One setting: the deployment key
Anything that talks to Boundri reads one environment variable:
export BOUNDRI_DEPLOYMENT_KEY=bdk_... # from `boundri deploy self` or `boundri keys create --deployment`
The key names its deployment (bdk_<16 hex>_... is deployment dep_<16 hex>),
so there is no project or organisation to configure. A deployment key reaches
four routes: evaluate, the deployment's own view, its own compiled bundle, and
the approval poll for an approval its own evaluation raised.
Management (agents, manifests, rules, keys) is the CLI's job, under an
organisation key or your login. Changes from the 0.1.0 line are in
CHANGELOG.md.
Front doors
Four in-process adapters and one separate process. All five take the same
decision through boundri_sdk.core.hook_gate, and one shared conformance suite
(tests/hooks/) asserts the same four behaviours against them, so they cannot
drift: an allow runs the tool, a deny does not, a duty is delivered before the
body, and a transport fault is a governed deny rather than an exception the
framework retries as a flaky tool.
| Framework | Seam | Wire it up | Extra |
|---|---|---|---|
| Claude Agent SDK | PreToolUse hook |
BoundriClaudeAgentAdapter(...).register_hooks(options) |
[claude-agent] |
| OpenAI Agents SDK | tool-input guardrail + handoff gate | BoundriOpenAIAgentsAdapter(...).register_hooks(agent) |
[openai-agents] |
| LangGraph | agent middleware | create_agent(..., middleware=[adapter.middleware()]) |
[langgraph] |
| CrewAI | before-tool-call hook |
BoundriCrewAIAdapter(...).register_hooks() |
[crewai] |
| LangChain | BaseTool wrapper |
adapter.protect(tools) |
— |
| MCP / HTTP | a separate process | boundri proxy run |
— |
Each takes an evaluator, a ToolManifest from your boundri.capabilities.yaml, and a
principal declared in config and never read off the call. Every framework is
an optional extra: pip install boundri-sdk installs none of them, and each
adapter imports cleanly with its framework absent, because the framework is
imported lazily inside registration. A runnable end-to-end example is
examples/langgraph_hook_demo/.
Which doors keep a record. A door records a decision only when the
evaluator it was given is AuditedLocalEvaluator(chain=ChainConfig(dir)). A
plain LocalEvaluator leaves no record at all. boundri proxy run and
boundri hook claude-code always write the chain.
When a record cannot be written, the chained log refuses the decision by
default (on_write_failure="deny"); the agent is told only that the record
could not be written (reason_code evaluator_error, details.cause
audit_record_unavailable), never a file path. "continue" serves the
decision unrecorded instead. Either way the loss is counted, and after the next
record that lands the log gets a sealed marker: "N records were lost between
these two times". boundri audit verify --log prints the count and still
passes, because a log that admits a loss has not been tampered with.
Limits, in plain words:
- The count lives in the process's memory. A crash, a kill, or a close that cannot write loses it. A marker proves a loss the process lived to report; it cannot prove there was no other.
boundri hook claude-coderuns one process per call, so a failed write there is one refused call, and a marker only if the disk recovers before it exits.- A local log is evidence held by whoever runs the SDK (the vendor, in an embedded deployment). Nothing here stops them turning logging off.
ChainConfig(key_path=...)(oraudit.key_pathinboundri.proxy.yaml) keeps the private notary key outside the log folder. Someone who can write the log folder but cannot read the key then cannot re-sign an edited log. Whoever holds the key still can, until local checkpoints are synced to the customer's chain. On Windows the key file is not made owner-only.
At registration each door reports three numbers: tools declared, how many
carry a resource_mapping, and how many of those mappings name a type. Read
the third: a tool whose mapping names no type (no mapping at all, or one that
maps only id or amount) is still evaluated, and its arguments reach
resource, but no type does, so a rule binding on resource.type is
undefined in Rego for it and can never fire. That holds even when the call
itself passes type= or id=: only the resource_mapping names the resource.
An argument the mapping does not consume stays readable as parameters.type /
parameters.id. An argument passed as None, mapped or not, is left out of
the input, as if it had not been sent, because Rego reads null as a value (null != "blocked" is true).
Each tool in boundri.capabilities.yaml may also say whether it reads or
writes: access: read or access: write, exactly those two words. It is
signed into the manifest your customer accepts and returned by the manifest
read routes (the dashboard does not show it yet). Leave it out when you are not sure: a missing marker means
"not stated", never "read". It changes no decision. Changing it changes the
manifest's hash, so publish a new version and your customer accepts again.
It needs boundri-sdk and boundri-cli at or above the release that added
it. Any loader ignores keys it does not know, so a typo such as acess: is
pushed as unmarked with no warning: check the key's spelling.
A resource_extractor that raises refuses the call: the LangChain door raises
ResourceExtractorError (a BoundriError) and the CrewAI hook blocks. The call
is never evaluated with a default resource.
The same holds on the hosted doors. A key the mapping sets wins over an
argument of the same name, so the customer's rules see the mapped value. The
hosted request has one parameters map, so under RemoteHookEvaluator
parameters.<key> then reads the mapped value as well, where local evaluation
keeps the argument there. The hosted LangChain and CrewAI doors with no
resource_extractor send the tool name as resource.id, never an argument.
The OpenAI door also gates handoffs. The SDK runs a transfer_to_<agent>
call through Handoff.on_invoke_handoff, not through a tool guardrail, so
register_hooks wraps that too and decides the transfer first. A refused
handoff raises HandoffRefusedError (a PermissionDeniedError) and ends the
run, because the SDK gives a handoff no way to hand a refusal back to the
model. A refused tool is different: its refusal goes back to the model as the
tool's result, and the agent carries on. register_hooks follows each handoff
to the agent it hands to and registers that agent too, and returns the number
of tools gated across all of them. A handoff whose target is chosen at run time
has no target to follow; the adapter names it in a warning, and that agent must
be registered by hand.
Failing closed
An agent that takes material actions must not be able to turn an outage, a stale bundle or a crash into an unchecked tool call. Five knobs control that, and every default is the fail-closed one.
A transport fault is a governed deny. RemoteEvaluator.evaluate does not
raise when the evaluator times out, cannot be reached, answers 5xx, or rate
limits (429). It returns an ordinary Deny your code already refuses on,
marked with a reason_code from the evaluator_* family
(boundri_ir.ReasonCode) and carrying details.transport. A 4xx other than
429 still raises RemoteEvaluationError — that is your request being wrong,
and denying it would hide the bug.
A governed deny has audit_id=None and no policy reference, because nothing
decided it. Read decision == "deny" and you refuse correctly; read
reason_code as well and you can tell "policy said no" from "nothing could
say yes".
A hosted decision carries reason_code too (null when a policy simply
decided), so one branch covers both doors:
if decision.reason_code is ReasonCode.NOT_GOVERNED: means no customer rule
reached this action. A code your SDK build predates arrives as the plain
string rather than raising, so a newer server never breaks an older runtime.
import os
from boundri_ir import GOVERNED_FAULT_CODES
from boundri_sdk import RemoteEvaluator
evaluator = RemoteEvaluator(
deployment_key=os.environ["BOUNDRI_DEPLOYMENT_KEY"], # or omit: read from the env
timeout_s=10.0, # or BOUNDRI_EVAL_TIMEOUT_S; default 30s
on_transport_error="deny", # the default; "raise" restores the old behaviour
)
decision = evaluator.evaluate_sync(principal, action, resource, parameters)
if decision.reason_code in GOVERNED_FAULT_CODES:
... # Boundri could not decide. The tool must not run.
The SDK never retries a fault on its own — a hidden retry doubles a timeout.
Retry it yourself with the same X-Boundri-Request-ID, which the server treats
idempotently, or pass on_transport_error="raise" and catch the httpx error.
A stale bundle can be given a bound. When every sync fails, the client
keeps enforcing its last good bundle — the right default, since a network blip
must not disarm your guardrails, but carried far enough it is policy nobody can
update. max_bundle_age_s sets a limit; past it, evaluate returns a governed
deny with reason_code="bundle_stale" and details naming the age, the bound
and the bundle version. It does not raise and it never falls back to allow.
The default is None (today's behaviour, unchanged).
client = BoundriClient(max_bundle_age_s=86_400) # BOUNDRI_DEPLOYMENT_KEY from the env
Age is measured from the last successful sync — a 304 Not Modified
counts, because the server has just confirmed the bundle is current — falling
back to the manifest's compiled_at for a consumer that never syncs. The
local proxy takes the same bound as bundle.max_age_s in boundri.proxy.yaml,
and bundle.deployment names the deployment the pack must have been built for
(a sibling deployment's pack, signed with the same customer key, is refused at
startup):
bundle:
path: ./packs/tenant
max_age_s: 86400
deployment: dep_0123456789abcdef
Duties on an allow reach your code. A regulation floor can say yes and
attach something you must do — DORA's "log the access event". Every adapter
takes an on_obligations hook, called with the obligations and an
ObligationContext before the tool body runs. With no hook they are logged
at INFO. A hook that raises blocks the call: a duty you could not accept is not
a duty discharged. Boundri surfaces duties; it does not discharge them.
def on_obligations(obligations, context):
for duty in obligations:
ledger.record(context.action_name, duty["id"])
config = LangChainAdapterConfig(on_obligations=on_obligations)
Both proxy doors refuse a fault. boundri proxy run answers the hosted
error envelope with status 500, code: "evaluator_error" and
retryable: true on its HTTP door, and a readable tool error carrying the same
code in structuredContent on its MCP door. Neither carries the exception
text; the detail goes to the operator's log.
Licence
Apache-2.0. See LICENSE. This package may not import packages/server/
(FSL); CI enforces the boundary.
Metadata
Release files for boundri-sdk 1.0.0rc1
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 |
|---|---|---|---|---|
| boundri_sdk-1.0.0rc1.tar.gz | 330.6 kB | With provenance | Details for boundri_sdk-1.0.0rc1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| boundri_sdk-1.0.0rc1-py3-none-any.whl | Python 3 | none | any | Details for boundri_sdk-1.0.0rc1-py3-none-any.whl |
Total release size: 653.4 kB
Release files / boundri_sdk-1.0.0rc1.tar.gz
| Download URL | boundri_sdk-1.0.0rc1.tar.gz |
|---|---|
| Size | 330.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6ecf42f5092c9152bee3b1801074679b72ed473e99d7661145169a81ce75d5b1
|
|
BLAKE2b-256 checksum How to use checksums |
57ba96b8410780c77f7a1e35ea6ab39752069c4603b2202db7fa4430e86f9256
|
| 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 Nov 13, 2026.
Transparency logRelease files / boundri_sdk-1.0.0rc1-py3-none-any.whl
| Download URL | boundri_sdk-1.0.0rc1-py3-none-any.whl |
|---|---|
| Size | 322.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
40d1c6b803ca609b3f72368fe68af7bb27148364ca70583357ef95b9d1279a1e
|
|
BLAKE2b-256 checksum How to use checksums |
7cbc2946f0447e69776681d9d7eefd2cee74a232b412c6bba393e833d554289c
|
| 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 Nov 13, 2026.
Transparency logSecurity for boundri-sdk 1.0.0rc1
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 boundri_sdk-1.0.0rc1.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 Nov 13, 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.