A policy & audit firewall for agent actions — authorise before a credential is used, require human approval for sensitive actions, and prove every action traces back to the instruction that authorised it.
Project description
delego
A policy & audit firewall for agent actions. It sits between an agent and whatever credential broker holds the user's secrets, and it answers the one question brokers don't: is this specific action the thing the human actually asked for?
agent ──propose──▶ delego ──if allowed──▶ credential broker ──▶ service
(LLM) (policy + (Agent Vault / (bank,
approval + OneCLI / SaaS,
audit) Browser Use…) API)
│
└── needs_approval ──▶ human (CLI)
📜 Protocol: delego implements protocol 0.2 of the open delego wire specification — canonicalization, the policy schema, intent/fingerprint binding, and the signed audit chain. The authorization token (spec 0.3) is specified but not yet implemented.
Why this exists
The "agent gets its own scoped credential, and never holds the user's secret directly" pattern is now a crowded, converging space — Infisical's Agent Vault, OneCLI, Browser Use, Nango, and others all do credential brokering.
The harder problem sits one level up — the confused deputy: the agent holds a valid credential, a prompt injection redirects it, the scope covers the action, so the broker happily injects the secret and the action goes through. The credential is the wrong place to catch this — it's valid. OAuth tokens carry no commitment to the original instruction.
Authorising the action (not just the credential) is an active area — see deterministic policy engines (OPA/Cedar, Permit), human-in-the-loop approval (HumanLayer), MCP gateways/firewalls, and the "pre-action authorization" line of research. delego is a small, deterministic, local, Apache-2.0 reference for it: no LLM in the decision path, no credential custody, approvals bound to the exact action fingerprint, and a signed, hash-chained audit trail — riding the existing broker layer rather than competing with it.
What it is / isn't
- Is a decision-and-audit layer. Deterministic policy, human approval for sensitive actions, signed append-only audit ledger.
- Isn't a credential vault or a proxy. It delegates execution to a broker
through a thin
BrokerAdapterinterface — you ride the existing layer instead of rebuilding it. - Authorisation is pure Python, no LLM in the loop. A model can advise upstream; the decision that gates a credential is made outside the stochastic loop, so an injection can't talk its way past it.
Key properties
- Intent binding — every action carries a hash of the original human instruction, recorded in the audit ledger and re-checked at resolve time, so an approval cannot be re-pointed at a different claimed instruction.
- Action-bound, single-use approval — a human "yes" is bound to one exact action fingerprint. An agent that gets approval for action A cannot reuse it to run action B (the confused-deputy guard), and cannot replay the same approval to run action A twice — an approval releases its action exactly once.
- Tamper-evident audit — receipts form an Ed25519-signed hash chain.
Editing, reordering, removing a receipt, or dropping a field breaks
verification, which reports the fault rather than trusting the ledger.
Caveats (be precise): hash-chaining does not catch truncation of the
most recent receipts (a tail-truncated prefix verifies clean), and the local
signing key protects nothing against a host compromise. For rollback
detection, anchor the head externally and pass it to
verify(expected_head=…); for key safety, use an HSM/KMS. See SECURITY.md.
Quickstart
pip install delego # the `delego` library + CLI
# pip install "delego[mcp]" # add the `delego-mcp` server (MCP is an optional extra)
delego init # creates ~/.delego with signing keys and an example policy
delego policy # inspect the active policy
To run the full loop end-to-end from a clone — an allowed read, a forbidden deny, an over-cap deny, an approval flow, the confused-deputy guard refusing a substituted action, and audit-chain tamper detection (no agent or live service needed):
git clone https://github.com/Delego-Dev/delego && cd delego
pip install -e ".[dev]"
python examples/demo.py
pytest
Human side (CLI)
delego policy # show the active policy
delego pending # list actions awaiting approval
delego approve apr_xxxx # release a parked action (or: delego deny apr_xxxx)
delego log -n 20 # read recent receipts
delego verify # check the audit chain (hashes, linkage, signatures)
Agent side (MCP) — wiring into Claude Code
delego ships an MCP server (delego_mcp) over stdio — install it with the mcp
extra: pip install "delego[mcp]". Register it in your MCP
config (for Claude Code, .mcp.json at the project root) so the agent can
propose actions. Set DELEGO_HOME to keep the policy, signing keys, and ledger
project-scoped under .claude/.delego:
{
"mcpServers": {
"delego": {
"command": "delego-mcp",
"env": { "DELEGO_HOME": "/abs/path/to/project/.claude/.delego" }
}
}
}
Initialise that home and approve from the same one (the CLI and MCP server must share a home):
delego --home .claude/.delego init # keys, example policy, and a .gitignore
delego --home .claude/.delego pending # ...then: delego --home .claude/.delego approve apr_xxxx
If DELEGO_HOME is unset, the CLI also auto-uses ./.claude/.delego when run
from the project root, falling back to ~/.delego. (Use an absolute path in the
MCP env, since the server's launch directory isn't guaranteed.)
Tools exposed:
| tool | what it does |
|---|---|
delego_propose_action |
submit an action; returns allow / deny / needs_approval |
delego_resolve_action |
complete an approved action (fingerprint must match) |
delego_audit_tail |
read recent receipts |
delego_show_policy |
show the active policy |
Typical flow: the agent calls delego_propose_action. If it comes back
needs_approval with an approval_id, a human runs delego approve <id>, then
the agent calls delego_resolve_action with the identical action to complete it.
Policy format
A rule matches on method / host / path (glob) / path_contains, decides
allow or needs_approval, and can attach constraints. Order is forbidden
(hard deny) → rules (first match wins) → default. A matched rule whose
constraints fail becomes a deny (fail-closed). See policy.example.yaml.
rules:
- name: place-order
decision: needs_approval
match: { method: POST, host: api.example.com, path: /orders }
constraints:
amount: { field: amount, max: 5000, currency: USD }
allow_list: { field: destination, in: [internal] }
Supported constraints: amount (cap + currency), allow_list
(field-in-set), rate_limit (max per minute/hour/day, counted from the ledger).
Build on delego
Three ways to use it, lowest friction first:
- As an MCP server —
delego init, add thedelego-mcpserver to your MCP config, and your agent proposes actions instead of executing them. No code. - As a library —
pip install delego, write a policy + aBrokerAdapter, and callfw.propose(...)in your tool-call path. - Behind a service — wrap the
Firewallin an HTTP API so many agents share one decision point and one audit chain.
The one extension point is the broker — where your credential lives and the authorised action actually runs. delego never holds the secret:
NullBroker(default) — simulates execution; for demos and tests.HTTPProxyBroker(gateway_url)— forwards the authorised action to an external credential gateway (OneCLI / vault / proxy) that injects the secret upstream.- Your own — implement
execute(action) -> dictagainst theBrokerAdapterprotocol indelego/brokers.py.
▶ Delego-Dev/sample-app — a FastAPI service built on the published package, with the full propose → approve → resolve loop and a copy-paste curl walkthrough. The best starting point for building your own.
See ROADMAP.md for where delego is going and where to help.
Status
- Implemented (protocol 0.2): the policy engine, intent hashing, action fingerprinting, the confused-deputy guard, intent-bound + single-use human approvals, and the signed, hash-chained audit ledger with verification.
- Brokers: the default
NullBrokerholds no credentials and makes no real request — it records what would be sent (for demos and tests).HTTPProxyBrokerforwards an authorised action to an external credential gateway; or write your own against theBrokerAdapterprotocol indelego/brokers.py. - Not yet: the authorization token (spec 0.3), an always-on daemon (state is file-backed and shared by the CLI and MCP server), and a non-MCP HTTP surface.
- Known limitations: concurrent writes to the file-backed ledger and approval
store are serialised with an OS file lock (corruption-safe), but rate-limit
exactness under concurrency still needs the planned single-writer daemon;
path globbing is coarse (
**and*collapse); the URL query string is not part of the action fingerprint (spec 0.3).
License
Licensed under the Apache License 2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file delego-0.2.2.tar.gz.
File metadata
- Download URL: delego-0.2.2.tar.gz
- Upload date:
- Size: 44.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29c9eba421e10363082c5c5ae7c991266b9239fdc965b35bd21c3f5115643b49
|
|
| MD5 |
e844dd5a62afe8c7df9185135c9a3935
|
|
| BLAKE2b-256 |
09eec83c356cdb8fc1cb604fc38ecdbd938fc197c64b38f298c4cf3637907c45
|
Provenance
The following attestation bundles were made for delego-0.2.2.tar.gz:
Publisher:
release.yml on Delego-Dev/delego
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
delego-0.2.2.tar.gz -
Subject digest:
29c9eba421e10363082c5c5ae7c991266b9239fdc965b35bd21c3f5115643b49 - Sigstore transparency entry: 1712707464
- Sigstore integration time:
-
Permalink:
Delego-Dev/delego@bb40babba302c4dd6dbc08e688271f3002294e04 -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/Delego-Dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bb40babba302c4dd6dbc08e688271f3002294e04 -
Trigger Event:
release
-
Statement type:
File details
Details for the file delego-0.2.2-py3-none-any.whl.
File metadata
- Download URL: delego-0.2.2-py3-none-any.whl
- Upload date:
- Size: 32.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4dc8b684ca9877c5fbdd2971fa43c9046c6f1b66b0ef022c7b94e2033d02b53c
|
|
| MD5 |
9c7878f6af49105833414dfb50bc8f67
|
|
| BLAKE2b-256 |
262ed53a945182697e43c758863600c553fb655b8118afccb193410ba8fb8be6
|
Provenance
The following attestation bundles were made for delego-0.2.2-py3-none-any.whl:
Publisher:
release.yml on Delego-Dev/delego
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
delego-0.2.2-py3-none-any.whl -
Subject digest:
4dc8b684ca9877c5fbdd2971fa43c9046c6f1b66b0ef022c7b94e2033d02b53c - Sigstore transparency entry: 1712707472
- Sigstore integration time:
-
Permalink:
Delego-Dev/delego@bb40babba302c4dd6dbc08e688271f3002294e04 -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/Delego-Dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bb40babba302c4dd6dbc08e688271f3002294e04 -
Trigger Event:
release
-
Statement type: