Guardian SDK for Python — Human Authority Infrastructure for Autonomous AI. Deterministic ALLOW/ASK/DENY before your agent's actions run, human approval for ASK, and offline-verifiable receipts.
pip install odingard-guardian==0.3.0 Copy PIP instructions
Human Authority Infrastructure for Autonomous AI. The agent proposes and the human decides. Every action your agent wants to take gets a deterministic ALLOW / ASK / DENY decision from Guardian before it runs. ASK waits for a human, and every execution produces a tamper-evident receipt you can verify offline.
Hosted Guardian: guardian.odingard.com. The free tier needs no card.
pip install odingard-guardian Python 3.9.2+. Dependencies: httpx, cryptography.
Guardian does not need to ship a connector for your provider. Wrap the function that performs the action (your Stripe call, your WhatsApp send, your production deploy, your database write) and Guardian decides whether it may run.
import os from odingard_guardian import ( Guard, GuardianClient, GuardianApprovalPending, GuardianDenied, ) client = GuardianClient(credential=os.environ["GUARDIAN_AGENT_CREDENTIAL"]) # gak_… per agent guard = Guard(client, connection_id=os.environ["GUARDIAN_CONNECTION_ID"]) @guard("pay_invoice") def pay_invoice(invoice_id: str, amount_cents: int, payee_id: str): return stripe.PaymentIntent.create(amount=amount_cents, currency="usd", ...) # your code try: pay_invoice("INV-1002", 1_240_000, "acme-supplies") except GuardianApprovalPending as held: # ASK: nothing ran notify_approver(held.request_id) ... # after the human approves: result = held.resume() # runs your function, records the receipt except GuardianDenied as denied: # DENY: your function never ran log.warning("blocked: %s", denied.reason_code) Decision What happens to your function ALLOW Runs once. Then the capability is redeemed and the receipt recorded (on_receipt= callback). ASK Does not run. GuardianApprovalPending.resume() runs it after approval; before approval it raises pending again. DENY Never runs. GuardianDenied.reason_code says why. An unreachable Guardian is a DENY (fail closed). An unreachable Guardian, or one that answers with a server error (HTTP 5xx), is refused with reason_code SERVICE_UNAVAILABLE: nothing ran, and it is reported as Guardian not answering, not as a denial. An answer whose decision is anything other than ALLOW, ASK or DENY is refused with MALFORMED_RESPONSE.
The proposal carries the tool name plus the call's bound arguments ({"invoice_id": …, "amount_cents": …, "payee_id": …}). The arguments are bound into the action and the receipt, so an approval does not carry over to changed arguments. Hosted Guardian decides Allow or Ask per tool today. Amount thresholds and payee rules on argument values are not evaluated yet; the invoice example shows them only under the local demo policy.
Approval binds the exact arguments. A file path is an argument; the file's contents are not, unless you declare the argument in file_args.
With file_args, the SDK on your machine reads the file, puts its SHA-256 in the approved arguments, and checks it again just before the tool runs. Guardian's servers never see the file. If the file changed, the call is refused with GuardianExecutionFailed (reason_code="CONTENT_CHANGED_SINCE_APPROVAL", local_effect_ran=False): your function does not run and a new approval is needed.
@guard(...) returns an ordinary function, so register the guarded function wherever your framework expects a tool. These are recipes, not separate integrations, and they are not all tested to the same level:
OpenAI Agents SDK (tested against Guardian; production proof pending):
CrewAI (example, not yet tested): @tool("Pay invoice") on top of @guard.
Claude Agent SDK (example, not yet tested): guard the handler, or put any MCP server behind guardian-mcp proxy (see the MCP package).
In-process mode is decision-gated. Your function runs after ALLOW and before the capability is redeemed. A revocation in that window is detected after the effect and raised as GuardianExecutionFailed(local_effect_ran=True) (or returned as a result that says the call ran, with on_execution_failed="result"). Treat that as an incident. Where Guardian itself must perform the call, use mode="remote" with a tool registered in your Guardian connection.
Guardian governs what goes through it. An agent or app that never calls Guardian is not governed by it.
Since 0.1.1, Guard does not try to register tools itself. install_record_transport=True turns that back on, but it is denied unless the agent's grant pins mcp.install, and it only works for a tool that has no entry yet. If Guardian answers that the tool is already registered, the call is refused (RECORD_TRANSPORT_UNVERIFIED) and nothing runs, because the existing entry may make an HTTP call. Which entries a Guard registered is kept in memory only, so a restarted process, another worker or a new Guard is refused that way even for an entry the SDK created itself; use the console-registered tool with the option off. Denials carry a hint with the next step, for example GuardianDenied.hint.
Hermes Agent runs its pre_tool_call plugin hook before every tool call. This package ships that hook as the Hermes plugin guardian:
# Hermes config.yaml (add guardian to plugins.enabled by hand) plugins: enabled: [guardian] hook_callback_timeout: 130 # Hermes blocks a hook that runs longer; 130 s fits a 2-minute ASK Set GUARDIAN_AGENT_CREDENTIAL, GUARDIAN_CONNECTION_ID (everyday tools) and GUARDIAN_HOOK_ASK_CONNECTION_ID (tools that need approval) in Hermes' environment. python -m odingard_guardian.hermes prints the console setup.
Read-only tools (read_file, search_files, web_search, …) are not routed, and anything outside Hermes' tool dispatch is not governed. Details, the Hosted setup and the MCP recipe: examples/hermes. Example, not yet tested against Guardian. The install step is unverified: in the only real attempt, hermes plugins enable guardian answered that the plugin was "not installed or bundled". Install odingard-guardian into the same Python environment Hermes runs in, list guardian under plugins.enabled in config.yaml yourself, and check that Hermes loads it before relying on it.
Hermes does not pin the contents of files its tools read. The path is bound; the file's bytes are not. (Hermes runs the tool itself after the hook returns, so there is no point just before it runs where the SDK could check the file. The write_file/patch contentDigest covers the call's own arguments, such as the new text the agent supplies, not the file on disk.)
from odingard_guardian import GuardianClient, classify_request_result client = GuardianClient(credential=..., base_url="https://guardian-api.odingard.com") result = client.request({ "action": "tool.invoke", "connection_id": "pcn_…", "tool_name": "refund_order", "arguments": {"orderId": "ord_123"}, }) d = classify_request_result(result) if d.decision == "ALLOW": client.execute(request_id=d.request_id, capability_token=d.capability_token) elif d.decision == "ASK": ... # keep d.request_id; client.claim(d.request_id) after the human approves The request goes to client.request, client.claim, client.execute, client.receipts and client.portable_receipt. It is sent as the same canonical action proposal the TypeScript SDK sends.
No account, credential or Guardian service is needed once you have the published keys:
from odingard_guardian import fetch_receipt_verification_keys, verify_receipt_offline keys = fetch_receipt_verification_keys("https://guardian-api.odingard.com")["keys"] receipt = client.portable_receipt(request_id).receipt # client: your GuardianClient verify_receipt_offline(receipt, keys) # {"valid": True, "decision": "ALLOW", "effect": "verified", "subject": {...}} # or {"valid": False, "reasonCode": "SIGNATURE_INVALID" | "EVIDENCE_CHAIN_INVALID" | ...} The verifier checks the Ed25519 signature over the guardian-canonical-json.v1 body, then re-derives every evidence record's hash and link, the authority lifecycle order, and every embedded object (decision, approval, capability, execution, effect). Its results and reason codes match the TypeScript SDK on the golden fixtures in tests/fixtures/ (generated by scripts/gen-fixtures.ts). The receipt envelope is schema-checked at the top level. Nested records are covered by the signature and digest re-derivation rather than a field-by-field schema.
An allowlist trusts the sender. When an agent asks your service to move money, check the request instead: is it exactly the action a person allowed, unchanged?
api.request cannot declare an amount, so pass "amount_field": "amount" (Stripe's form field) to read it from the signed request body instead. With no declared amount, Guardian checked it against no cap, so it is accepted only when a person approved the request.
The body is read only for a known JSON or form content type; anything else is refused.
Its verdicts match the TypeScript verifyBeforeActing on 79 golden cases (tests/fixtures/verify-before-acting.json, generated by scripts/gen-vba-fixtures.ts).
cd packages/python uv venv && uv pip install -e ".[test]" .venv/bin/python -m pytest # regenerate cross-language fixtures (from the repo root, after npm install): npm run fixtures:python Apache-2.0.
agentic-commerce ai-agents authority authorization guardian human-in-the-loop mcp
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
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.
None of the files in this release were uploaded with provenance metadata.
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.




