CAGE: credential containment for AI agents. Capability-token-gated, structurally refusing, audit-chained.
pip install cage-ai==0.1.4 Copy PIP instructions
Credential containment for AI agents. Capability-token-gated, structurally refusing, audit-chained.
We don't filter what the agent says. We cage what the agent can do.
CAGE is AI control infrastructure: the authority layer that decides what an autonomous agent is allowed to do. It sits above secret stores and HSMs, and away from prompt filters. It replaces the persistent API key with short-lived, scope-bound capability tokens, optionally bound to a context. With the broker deployed as DEPLOY.md describes, a prompt-injected or otherwise compromised agent never holds the credential it works with.
The engine is Rust. Python is the first client. On the Rust backend (the bundled native extension) the master key lives only in Rust-owned memory and never crosses into Python as plaintext. Python is a thin binding that holds capability tokens. It came first because the AI-agent ecosystem (LangChain, the provider SDKs) lives there, and the broker speaks a language-neutral protocol, so clients in other languages can follow. The out-of-process broker goes further: the agent runs in a separate process holding only token IDs, and the key never enters its address space.
Three terms from capability security and the agent-safety literature place CAGE:
CAGE provides process verifiability: cryptographic evidence, on an append-only chain, of what an agent was authorized to do and what it attempted. Whether the agent did the right thing is a separate question for a separate layer. CAGE constrains capability and does not evaluate intent.
import cage gives you the pure-Python authority core, with no native extension and no third-party dependencies. It gates any action with a capability token and a tamper-evident audit chain:
import cage gate = cage.Gate() token = gate.issue_token(scope="db.write", context="job-42", ttl_seconds=60, max_uses=1) gate.authorize_and_charge(token, "db.write") # authorize + charge one use atomically, or raise CageViolation do_the_write() # your gated action The secret-custody and LLM transport ring loads only when you reach for it. LLM calls need the bundled native extension, and the pure-Python fallback refuses them:
from cage import vault vault.store_secret("llm_api_key", api_key) # encrypts into Rust-owned memory # Fail-closed by default: unseal once for the bootstrap (the authority root), # then pass it to every issue_token / revoke. On the Rust backend unseal() # returns an opaque handle, so the secret stays in Rust memory. # In production, broker_only_issuance=True routes issuance through the # out-of-process broker so the authority never lives in your process. bootstrap = vault.unseal() token = vault.issue_token( scope="llm.evaluate", context="security-audit-run-42", ttl_seconds=60, max_uses=3, bootstrap_token=bootstrap, ) # The decrypted key never crosses into Python. # provider= selects the transport ("anthropic" by default, "openai" also wired). response = await vault.invoke_llm(token, { "model": "claude-haiku-4-5", "max_tokens": 200, "messages": [{"role": "user", "content": "..."}], }) For the strongest containment, run the out-of-process broker. The key lives in a separate process and the agent holds only token IDs. cage.broker.spawn_broker starts it, and cage.adapters.CagedAnthropic / CagedOpenAI take the provider SDKs' call shape (they return the provider's JSON as a dict). The broker needs an issuance policy, so set CAGE_ISSUANCE_SCOPES (for example llm.,sign.) before you start it. See examples/broker_demo.py, which drives a real agent child process that is refused every escalation, and examples/agent_broker_adapter.py. Read DEPLOY.md before running the broker in production: it only keeps the key from a same-user agent when the agent cannot control how the broker starts.
CAGE is built to contain a compromised agent: an LLM agent driven by prompt injection, or agent code that turned hostile, running in its own process and possibly as the same OS user as the broker. Against that agent the broker keeps the key out of reach, provided the agent cannot write the broker binary, its launcher or its environment (see DEPLOY.md). A remote attacker holding the operator key is bounded by the frozen issuance policy, where one is provisioned. Root, the kernel, and anyone who controls how the broker starts are out of scope. CAGE does not claim to defeat an adversary with unrestricted code execution on the host. It aims to make credential compromise slow and visible.
These are the gaps as of v0.1. Reports and fixes are welcome (see SECURITY.md).
Every CAGE wheel published on GitHub Releases is signed with Sigstore through GitHub Actions OIDC and Fulcio. The signing is keyless: no long-lived signing key exists in the repo or in CI. Every signature is recorded in the public Rekor transparency log. Releases after v0.1.2 also carry a signed sdist and a signed CycloneDX SBOM (cage_ai-X.Y.Z.cdx.json) that lists the Rust crates compiled into the wheels.
To verify a downloaded wheel before installing:
cosign verify-blob \ --certificate cage_ai-X.Y.Z-*.whl.cert \ --signature cage_ai-X.Y.Z-*.whl.sig \ --certificate-identity \ "https://github.com/derdelean/cage/.github/workflows/release.yml@refs/tags/vX.Y.Z" \ --certificate-oidc-issuer https://token.actions.githubusercontent.com \ cage_ai-X.Y.Z-*.whl A passing verification proves the wheel was built by this repository's release workflow at the tag vX.Y.Z, and the proof is publicly recorded in Rekor. The same workflow publishes to PyPI through trusted publishing (no API token), and PyPI shows a Sigstore attestation for each file. CAGE proposes credential containment through capability tokens and an audit chain, and its own releases are signed with the same Sigstore, Fulcio and Rekor model.
From PyPI (the distribution is named cage-ai, the import stays import cage):
pip install cage-ai Or install a signed wheel from GitHub Releases (verify it first, as above), or build from source:
uv pip install maturin maturin develop --release A bare import cage (the authority core) needs no native extension. The vault and transport ring load it on first use.
To use CAGE from another local project, build a wheel and install it:
maturin build --release # -> target/wheels/cage_ai-0.1.4-*.whl pip install target/wheels/cage_ai-0.1.4-*.whl or reference the checkout as a path dependency:
# pyproject.toml of the consuming project (uv) [tool.uv.sources] cage-ai = { path = "../cage" } Locally built wheels are not signed.
CAGE is open-source under the Apache License 2.0. Two Swiss patent applications are pending, filed on 21 October 2025 and 19 September 2026. They will not be enforced offensively against good-faith users. See PATENT_PLEDGE.md for the binding defensive-only pledge, modeled on Tesla's 2014 EV patent pledge and the Open Invention Network.
Apache 2.0 with a defensive-only patent pledge. Built in Switzerland.
All 9 files in this release have provenance metadata.
security cryptography ai-agents capability-tokens
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Enable javascript to be able to filter the list of wheel files.
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 verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.
All 9 files in this release have been 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.




