Skip to main content

agent-authority (Python)

Authorization for AI agents — the reference implementation of agent authority (project name: Behalf). Verifiable, scoped, time-bound, revocable capability tokens (mandates) with attenuable, macaroon/biscuit-style delegation, plus MCP and agent-to-agent (A2A) middleware. Capability-based security, OAuth 2.1 on-behalf-of–style grants, and SPIFFE/SVID-style agent identity for multi-agent / LLM systems.

Identical API shape to the TypeScript library, zero dependencies (standard library only). The optional cryptography extra enables a constant-time Ed25519 backend and sealed credentials:

pip install agent-authority          # core, dependency-free
pip install "agent-authority[seal]"  # + sealed credentials / hardened crypto

In plain words

Think of a Mandate as a permission slip for an AI agent.

Imagine you hire an assistant to run errands for you. You don't hand over your wallet and house keys — you write a note: "You may read my calendar and spend up to $50, and only for the next hour." That note is a Mandate.

The five verbs are just the things you can do with that note:

  • grant — write the permission slip. "This agent may do X, up to this limit, until this time."
  • authorize — check the slip before acting. The agent must show the slip (and prove it's really theirs) before it's allowed to do something.
  • attenuate — make a smaller copy for a helper. A sub-agent can only get the same powers or fewer — never more.
  • revoke — tear the slip up. Cancel it instantly; every copy handed downstream stops working too.
  • audit — the logbook. Every check is written down, so you can see exactly what happened.

Two things make the slip safe: it can't be faked or upgraded (it's signed with cryptography, and a helper can only shrink the powers), and holding the paper isn't enough — an agent must prove it's the rightful holder, so a stolen copy by itself is useless.

The rest of this page shows how to do each of these in code.

The five verbs

from agent_authority import create_behalf

b = create_behalf()

# 1. GRANT
mandate = b.grant(
    principal="alice",
    agent="research-agent",
    can=["read:calendar", "spend:usd<=50"],
    expires_in="1h",
)

# 2. AUTHORIZE — raises AuthorizationError if denied
mandate.authorize("spend:usd=20")

# 3. ATTENUATE — narrow for a sub-agent; can only shrink
child = mandate.attenuate(can=["read:calendar"], expires_in="10m")

# 4. REVOKE — kills the mandate and its downstream chain
b.revoke(mandate.id)

# 5. AUDIT — every authorize() wrote a hash-chained record
trail = b.audit(mandate.id)

MCP / A2A middleware

from agent_authority.mcp import with_behalf

server = with_behalf(
    my_tool_server,  # exposes call_tool(name, args, ctx=None)
    policy={
        "send_email": "write:email",
        "read_calendar": "read:calendar",
        "transfer_funds": lambda args: f"spend:usd<={args['amount']}",
    },
    on_denied="throw",  # or "prompt" with on_prompt=...
)

# Pass the caller's mandate on the context:
server.call_tool("read_calendar", {}, {"mandate": mandate})

agent_authority.mcp.behalf_mcp_tools() returns the three discovery tools (request_mandate, present_mandate, check_authority).

Develop

python3 -m unittest discover -s tests   # 28 tests

Metadata

Release files for agent-authority 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agent-authority 0.1.6
File Size Uploaded Provenance
agent_authority-0.1.6.tar.gz 48.1 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for agent-authority 0.1.6
File Interpreter ABI Platform
agent_authority-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 91.1 kB

Release files / agent_authority-0.1.6.tar.gz

Download URL agent_authority-0.1.6.tar.gz
Size 48.1 kB
Tags Source
SHA-256 checksum
How to use checksums
04e8884fea60d51f54fb9a4af5e14b6fb1059b82cf70cb2003aee7f50ebfbd98
BLAKE2b-256 checksum
How to use checksums
2598bc833f19698986a0180269fb8e736676888453ccb53f1ff8590e9c22c9b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 14, 2026.

Transparency log

Release files / agent_authority-0.1.6-py3-none-any.whl

Download URL agent_authority-0.1.6-py3-none-any.whl
Size 43.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
646c60a34b6c526f6321f73bd8424e89f73419de9a2c59c9cb63fc15684b779e
BLAKE2b-256 checksum
How to use checksums
c340fd9fa6b829f9477830b1477719b7a6ca166fc35ccaaa1743a508200a04b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 14, 2026.

Transparency log

Security for agent-authority 0.1.6

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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for agent_authority-0.1.6.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 Jun 14, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page