Skip to content

About

Python SDK for Agent Passport System identity, scoped delegation and signed receipts.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Agent Passport System: Python SDK

PyPI

Enforcement and accountability layer for AI agents. Bring your own identity. Python implementation of the Agent Passport Protocol, cross-language compatible with the TypeScript SDK. Signatures created in Python verify in TypeScript and the reverse. The Python port is a strict subset of the TS SDK. See the note under "What's Included" below for the current scope boundary.

Install

pip install agent-passport-system

Current stable: the version on PyPI, installed by default with pip install agent-passport-system. The 2.4 line added the Wave 1 accountability primitives (ActionReceipt, AuthorityBoundaryReceipt, CustodyReceipt, ContestabilityReceipt, APSBundle), Cognitive Attestation (Paper 4), and Instruction Provenance Receipts (v0.2). It also adds evidentiary type safety: a claim and evidence registry, a claim verifier, and a contestation cascade. All primitives are tested for byte-identical canonical JSON against fixtures generated by the TypeScript SDK at version 2.6.0-alpha.0.

Quick Start

This program issues an AuthorityDelegationV1 grant, verifies it with an explicit clock, key resolver, root trust policy and revocation resolver, reserves spend through a verifier bound to the budget ledger, then revokes the grant. It was run against the published 5.0.0 wheel and printed the output below. generate_key_pair() returns the keys publicKey and privateKey. The older create_passport and create_delegation functions produce the pre-draft compatibility formats.

from agent_passport import (
    AuthorityVerifierConfig, InMemoryAuthorityBudgetLedger, create_authority_chain_verifier,
    generate_key_pair, verify_authority_chain_for_budget,
)
from agent_passport.v2.authority_delegation import issue_authority_delegation, verify_authority_delegation
from agent_passport.v2.authority_revocation import (
    InMemoryAuthorityRevocationStore, create_authority_revocation_resolver,
    issue_authority_revocation, record_authority_revocation,
)

principal = generate_key_pair()
PRINCIPAL, PRINCIPAL_VM = "did:example:principal", "did:example:principal#key-1"

grant = issue_authority_delegation({
    "record_type": "aps:authority-delegation:v1", "version": "1.0", "parent_delegation_id": None,
    "issuer": PRINCIPAL, "subject": "did:example:agent", "verification_method": PRINCIPAL_VM,
    "issued_at": "2026-10-28T09:00:00.000Z", "nonce": "00000000000000000000000000000001",
    "authority": {
        "scope": {"profile": "aps-hierarchical-v1", "grants": ["notes:read:*"]},
        "spend": {"mode": "bounded", "unit": "example:credit", "per_action": "5", "cumulative": "10"},
        "depth": {"remaining": 0},
        "time": {"not_before": "2026-10-28T09:00:00.000Z", "not_after": "2026-10-28T17:00:00.000Z"},
        "reputation": {"profile": "aps-score-0-100-v1", "ceiling": 100},
        "values": {"profile": "aps-values-identifiers-v1", "required": []},
        "reversibility": {"profile": "aps-tci-v1", "ceiling": "compensable"},
    },
}, principal["privateKey"])

def resolve_key(issuer, verification_method, issued_at):
    if issuer == PRINCIPAL and verification_method == PRINCIPAL_VM:
        return principal["publicKey"]
    return {"outcome": "not_found"}

store = InMemoryAuthorityRevocationStore()
store.track(grant["delegation_id"])
resolve_revocation = create_authority_revocation_resolver(store, resolve_verification_key=resolve_key)

def check(now):
    r = verify_authority_delegation(grant, now=now, resolve_verification_key=resolve_key,
        trust_root=lambda root: root["issuer"] == PRINCIPAL, resolve_revocation=resolve_revocation)
    return r.state, [f.code for f in r.failures]

print("check at 10:00", check("2026-10-28T10:00:00.000Z"))
print("check at 18:00", check("2026-10-28T18:00:00.000Z"))
# Budget reservations take a handle from the ledger's own verifier.
def reserve(now, action_ref):
    verifier = create_authority_chain_verifier(AuthorityVerifierConfig(
        "example-policy", "in-memory", lambda: now, resolve_key,
        lambda root: root["issuer"] == PRINCIPAL, resolve_revocation))
    checked = verify_authority_chain_for_budget([grant], verifier)
    if not checked.ok:
        return "no handle", [f.code for f in checked.result.failures]
    ledger = InMemoryAuthorityBudgetLedger(verifier, now=lambda: now)
    return ledger.reserve(checked.chain, action_ref, "example:credit", "5").code

print("reserve at 10:00", reserve("2026-10-28T10:00:00.000Z", "a" * 64))
revocation = issue_authority_revocation(grant, now="2026-10-28T10:05:00.000Z", revoker=PRINCIPAL,
    verification_method=PRINCIPAL_VM, reason_code="task_complete",
    nonce="000000000000000000000000000000aa", private_key=principal["privateKey"])
recorded = record_authority_revocation(store, grant, revocation, resolve_verification_key=resolve_key)
print("revocation recorded", recorded.recorded, recorded.verification.state)
print("check at 10:10", check("2026-10-28T10:10:00.000Z"))
print("reserve at 10:10", reserve("2026-10-28T10:10:00.000Z", "b" * 64))
check at 10:00 ('valid', [])
check at 18:00 ('invalid', ['EXPIRED'])
reserve at 10:00 RESERVED
revocation recorded True valid
check at 10:10 ('invalid', ['REVOKED'])
reserve at 10:10 ('no handle', ['REVOKED'])

A verified handle records one verification. A handle obtained before a revocation still reserves until its validity window ends, unless the ledger is given max_verification_age_ms, so verify current authority again before dispatch. See MIGRATION.md for the 5.0.0 budget API.

What's Included

Module Layer What It Does
crypto base Ed25519 key generation, signing, verification
canonical base Deterministic JSON serialization (cross-language compatible)
passport 1 Agent identity creation, signing, verification, expiry
delegation 1 Pre-draft compatibility delegation chains, sub-delegation, revocation. Deprecated, frozen, not on the draft-03 path
v2.authority_delegation 1 AuthorityDelegationV1, the draft-03 delegated authority record: closed schema, seven-facet narrowing, chain verification with an explicit now and caller-supplied key, trust and revocation resolvers, and an in-memory spend ledger
values 2 Human Values Floor: load YAML/JSON, attestation, compliance, graduated enforcement
attribution 3 Merkle proofs, beneficiary tracing, contribution tracking
agora 4 Signed message feeds, topics, threading, agent registry
intent 5a Roles, deliberation, consensus, tradeoff evaluation, precedents
policy 5b 3-signature chain, FloorValidatorV1, action intents
coordination 6 Task lifecycle: briefs, evidence, review, handoff, deliverables
integration 7 Cross-layer bridges (commerce+intent, coord+agora, etc.)
commerce 8 4-gate checkout, human approval, spend tracking, receipts

Cross-Language Compatibility

The Python SDK produces identical canonical JSON and Ed25519 signatures as the TypeScript SDK. This means:

  • A passport signed in Python can be verified in TypeScript Two delegation records ship, and they are not interchangeable. AuthorityDelegationV1 (record_type aps:authority-delegation:v1) in v2.authority_delegation is the delegated authority record of draft-pidlisnyi-aps-03 section 3.1, with the seven signed facets and a chain verifier that returns valid, invalid, indeterminate or unsupported. The older Delegation from create_delegation, sub_delegate and verify_delegation is a pre-draft compatibility surface, deprecated and frozen: it predates the draft wire format and is not on the draft path. Its scope rules are pre-draft too and differ from section 3.2 in both directions, which is recorded on each function. New work uses AuthorityDelegationV1.

  • Delegation chains can span Python and TypeScript agents

  • Merkle roots computed from the same receipts match across languages

from agent_passport import canonical_json

# Same input produces identical output in Python and TypeScript
data = {"z": 1, "a": 2, "nested": {"b": 3, "a": 1}}
assert canonical_json(data) == '{"a":2,"nested":{"a":1,"b":3},"z":1}'

Verification boundary

The verification boundary names the verification APIs that establish authority from caller-supplied trust, and the trust input each one takes.

Protocol Layers

This Python SDK implements all 8 Agent Passport Protocol layers:

  1. Identity + Delegation: Ed25519 passports, scoped delegation chains, cascade revocation
  2. Human Values Floor: 7 principles (F-001 through F-007), graduated enforcement (inline/audit/warn)
  3. Beneficiary Attribution: Merkle proofs for contribution tracking
  4. Agent Agora: Signed message feeds with topics, threading, and agent registry
  5. Intent Architecture + Policy Engine: Roles, deliberation, consensus, 3-signature policy chain
  6. Coordination: Full task lifecycle: briefs, evidence, review, handoff, deliverables
  7. Integration Wiring: Cross-layer bridges (commerce+intent, coordination+agora)
  8. Agentic Commerce: 4-gate checkout, human approval, spend limits

Cross-language parity with the TypeScript SDK at the reference version pinned in this repository's fixtures. The current release ships the full Wave 1 surface: ActionReceipt, AuthorityBoundaryReceipt, CustodyReceipt, ContestabilityReceipt, APSBundle (with balanced Merkle commitment), Cognitive Attestation (Paper 4: three-stage verification, typed dispute primitives), and Instruction Provenance Receipts v0.2 (path canonicalization, context-root binding, action-time recompute). The four evidentiary type safety primitives also ship. All surfaces are tested against TS-issued fixtures for byte-identical canonical JSON. Cross-language signature verification covers every signed primitive in the SDK. Also available via the MCP server.

Links

Tests

pip install -e ".[test]"
pytest tests/
# the tally is whatever pytest reports on the current checkout
# plus the v2 evidentiary type safety, Wave 1 accountability, Cognitive Attestation,
# and Instruction Provenance Receipt surfaces. The cross-impl byte-parity tests assert
# byte-identical canonical JSON against TS-issued fixtures (rfc8785 ships in the test
# extra). Two cross-language tests also need the agent-passport-system TS SDK checked
# out next to this repo; without that sibling they skip.

License

Apache-2.0

Budget callers migrating to the 5.0.0 API should follow MIGRATION.md. Reservations now require a handle issued by the same configured verifier used by the ledger.

About

Python SDK for Agent Passport System identity, scoped delegation and signed receipts.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages