Python SDK for the Agent Receipts protocol
Project description
agent-receipts
Python SDK for the Agent Receipts protocol
Create, sign, hash-chain, store, and verify cryptographically signed audit trails for AI agent actions.
Why receipts?
If you're building with AI agents, you're probably already logging what they do. Receipts go further: they're cryptographically signed, hash-chained records that can't be quietly altered after the fact — and they follow a standard format that works across languages, agents, and systems.
Here's where that matters in practice:
-
Post-incident review — An agent ran overnight and something broke. The receipt chain shows exactly which actions it took, in what order, and whether each succeeded or failed — with cryptographic proof the log hasn't been tampered with after the fact.
-
Compliance and audit — Regulated environments require evidence of what systems did and why. Receipts are W3C Verifiable Credentials with Ed25519 signatures, giving auditors a tamper-evident trail they can independently verify.
-
Safer autonomous agents — Agents can query their own audit trail mid-session. Before taking a high-risk action, an agent can check what it has already done and whether previous steps succeeded, enabling self-correcting workflows.
-
Multi-agent trust — When agents collaborate, receipts serve as proof of prior actions. Agent B can verify that Agent A actually completed step 1 before proceeding to step 2, without trusting a shared log.
-
Usage tracking — Every action is classified by type and risk level, giving you a structured breakdown of what agents spent their time on.
Beyond local storage
The protocol is designed for receipts to travel — publishing to a shared ledger, forwarding to a compliance system, or exchanging between agents as proof of prior actions. Receipts are portable W3C Verifiable Credentials, but where they go is always under the user's control.
Install
pip install agent-receipts
Quick start
Create and sign a receipt
from agent_receipts import (
create_receipt,
generate_key_pair,
hash_receipt,
sign_receipt,
CreateReceiptInput,
Chain,
Issuer,
Outcome,
Principal,
)
from agent_receipts.receipt.create import ActionInput
# Generate an Ed25519 key pair
keys = generate_key_pair()
# Create an unsigned receipt
unsigned = create_receipt(CreateReceiptInput(
issuer=Issuer(id="did:agent:my-agent"),
principal=Principal(id="did:user:alice"),
action=ActionInput(
type="filesystem.file.read",
risk_level="low",
),
outcome=Outcome(status="success"),
chain=Chain(
sequence=1,
previous_receipt_hash=None,
chain_id="chain_session-1",
),
))
# Sign and hash
receipt = sign_receipt(unsigned, keys.private_key, "did:agent:my-agent#key-1")
receipt_hash = hash_receipt(receipt)
Verify a receipt
from agent_receipts import verify_receipt
valid = verify_receipt(receipt, keys.public_key)
print(f"Signature valid: {valid}") # True
Verify a chain
from agent_receipts import verify_chain
# Verify a list of receipts (e.g. [receipt] from the example above)
result = verify_chain([receipt], keys.public_key)
print(f"Chain valid: {result.valid}")
print(f"Receipts verified: {result.length}")
if not result.valid:
print(f"Broken at index: {result.broken_at}")
Action taxonomy
The standardized action taxonomy (action types and risk levels) is defined in the protocol specification. Taxonomy classification will be added in a future milestone (M3).
What is an Agent Receipt?
A W3C Verifiable Credential signed with Ed25519, recording:
| Field | What it captures |
|---|---|
| Action | What happened, classified by a standardized taxonomy |
| Principal | Who authorized it (human or organization) |
| Issuer | Which agent performed it |
| Outcome | Success/failure, reversibility, undo method |
| Chain | SHA-256 hash link to the previous receipt (tamper-evident) |
| Privacy | Parameters are hashed, never stored in plaintext |
API reference
Receipt creation and signing
from agent_receipts import (
create_receipt, # Build an unsigned receipt from input fields
generate_key_pair, # Ed25519 key pair (PEM-encoded)
sign_receipt, # Sign with Ed25519Signature2020 proof
verify_receipt, # Verify a receipt's signature
)
Hashing and canonicalization
from agent_receipts import (
canonicalize, # RFC 8785 JSON canonicalization
hash_receipt, # Hash receipt (excluding proof) -> "sha256:<hex>"
sha256, # Hash arbitrary data -> "sha256:<hex>"
)
Chain verification
from agent_receipts import (
verify_chain, # Verify signatures, hash links, and sequence numbering
)
Types (Pydantic v2 models)
from agent_receipts import (
ActionReceipt, # Signed receipt with proof
UnsignedActionReceipt, # Receipt before signing
Action, ActionTarget, Authorization, Chain,
CredentialSubject, Intent, Issuer, Operator,
Outcome, Principal, Proof, StateChange,
)
Subpackage imports
from agent_receipts.receipt import create_receipt, sign_receipt
from agent_receipts.receipt.hash import canonicalize
from agent_receipts.receipt.types import CONTEXT, CREDENTIAL_TYPE
TypeScript SDK compatibility
camelCase aliases are available for users coming from the TS SDK:
from agent_receipts import (
createReceipt, # = create_receipt
generateKeyPair, # = generate_key_pair
signReceipt, # = sign_receipt
verifyReceipt, # = verify_receipt
hashReceipt, # = hash_receipt
verifyChain, # = verify_chain
)
Cross-language compatibility
This SDK produces byte-identical output to @agnt-rcpt/sdk-ts:
- RFC 8785 canonical JSON matches exactly
- SHA-256 hashes are identical
- Ed25519 signatures from either SDK verify in the other
Cross-language compatibility is verified by test vectors generated from the TypeScript SDK.
Project structure
src/agent_receipts/
receipt/
types.py # Pydantic models for all receipt types
create.py # Receipt creation with auto-generated IDs
signing.py # Ed25519 signing and verification
hash.py # RFC 8785 canonicalization + SHA-256
chain.py # Chain verification
Development
uv sync --all-extras
uv run pytest # run tests
uv run ruff check . # lint
uv run ruff format . # format
uv run pyright # type check
| Language | Python 3.11+ |
| Types | Pydantic v2, pyright strict mode |
| Linting | ruff |
| Testing | pytest |
| Dependencies | pydantic>=2.0, cryptography>=41.0 |
Ecosystem
| Repository | Description |
|---|---|
| agent-receipts/spec | Protocol specification, JSON Schemas, canonical taxonomy |
| agent-receipts/sdk-ts | TypeScript SDK (npm) |
| agent-receipts/sdk-py (this package) | Python SDK |
| ojongerius/attest | MCP proxy + CLI (reference implementation) |
License
Apache 2.0 — see LICENSE.
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 agent_receipts-0.8.0a2.tar.gz.
File metadata
- Download URL: agent_receipts-0.8.0a2.tar.gz
- Upload date:
- Size: 90.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f990364dd0ea6f7c084c34789515dd2efda8b6794a52ac2b247d18f2be407ce
|
|
| MD5 |
2edee3effc3718fcd1acbaaa29382509
|
|
| BLAKE2b-256 |
069b153eb10aec05cdd39b5bb391eab2d51f1e2c783cf22f1c6608c703acda54
|
Provenance
The following attestation bundles were made for agent_receipts-0.8.0a2.tar.gz:
Publisher:
publish-py.yml on agent-receipts/ar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_receipts-0.8.0a2.tar.gz -
Subject digest:
8f990364dd0ea6f7c084c34789515dd2efda8b6794a52ac2b247d18f2be407ce - Sigstore transparency entry: 1487273475
- Sigstore integration time:
-
Permalink:
agent-receipts/ar@48fe36a0f258c658bc919dd0f886df376752c66c -
Branch / Tag:
refs/tags/sdk-py-v0.8.0a2 - Owner: https://github.com/agent-receipts
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-py.yml@48fe36a0f258c658bc919dd0f886df376752c66c -
Trigger Event:
release
-
Statement type:
File details
Details for the file agent_receipts-0.8.0a2-py3-none-any.whl.
File metadata
- Download URL: agent_receipts-0.8.0a2-py3-none-any.whl
- Upload date:
- Size: 30.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cfed2c98b6064dcdb8236730634fa0b35efefa836cff5defe0cf992960a12b6
|
|
| MD5 |
e633c0a020f8a7bfd5f1aab4624a123a
|
|
| BLAKE2b-256 |
700a47a597f291df8e19906de24b8fc215687b26326f435367b01cb195148fb5
|
Provenance
The following attestation bundles were made for agent_receipts-0.8.0a2-py3-none-any.whl:
Publisher:
publish-py.yml on agent-receipts/ar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_receipts-0.8.0a2-py3-none-any.whl -
Subject digest:
9cfed2c98b6064dcdb8236730634fa0b35efefa836cff5defe0cf992960a12b6 - Sigstore transparency entry: 1487273505
- Sigstore integration time:
-
Permalink:
agent-receipts/ar@48fe36a0f258c658bc919dd0f886df376752c66c -
Branch / Tag:
refs/tags/sdk-py-v0.8.0a2 - Owner: https://github.com/agent-receipts
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-py.yml@48fe36a0f258c658bc919dd0f886df376752c66c -
Trigger Event:
release
-
Statement type: