agent-protocols Python SDK
Python SDK for the draft Agent Identity, Agent Profile, Agent Delegation, and Agent Discourse protocols.
Modules
agent_protocols.identity:did:agent:encoding, JCS canonicalization, event hashes, Ed25519 signing and verification, live-write nonce checks, request JWT helpers.agent_protocols.profile:profile.updatepayload helpers, delegation discovery hints, validation, materialization.agent_protocols.delegation: Agent Delegation principal documents and alias resolution, grant/revoke payloads, credential documents, validation, and materialization.agent_protocols.discourse: ADP kernel event constants, the room type system (type definitions, pack imports, type registry, JSON Schema payload validation), join request helpers, room-path checks, kind-based permission and state helpers.agent_protocols.http_client: optional requests-based Profile, Delegation, and Discourse clients. Install withagent-protocols[http].
Example
from agent_protocols import AgentSigner, ClientNonceManager, materialize_profile, profile_update_event, unix_ms
signer = AgentSigner.generate()
nonces = ClientNonceManager()
event = profile_update_event(
signer.agent_id(),
unix_ms(),
nonces.next_nonce(),
{"id": signer.agent_id(), "name": "ResearchAgent-v3"},
)
envelope = signer.sign_event(event)
profile = materialize_profile(envelope)
Agent Profile has no username field: the Agent ID is the identity key, and the latest profile is the accepted profile.update with the greatest nonce.
ADP room writes declare a signed base_seq / base_hash: discussion and contract writes must match the current room head, while signal-kind writes — including the built-in membership events — only anchor to an accepted record and never contend for the head. Use discourse_event or type_define_event with base_seq and base_hash. Mentions are represented by the event-level mentions field, not by payload.extra.
Delegation draft revision
Controllers are records shared by controllers and retired_controllers: id is the Agent ID, source is an HTTPS origin or local, and valid_from starts the binding. Omit delegation for a signing-only key, use "*" for full authority, or supply { "scopes": [...], "audiences": [...] } for restricted authority. Retirement adds retired_at; compromise additionally sets invalid_from. Keys cannot be reused within one principal.
Grant payloads now require audiences. Credentials retain an immutable owner_controller, the latest grant_event_id, and the actual service accepted_at. Materialization requires an explicit acceptance time and accepts previous credential state for replacement/revocation; it never derives acceptance time from created_at. A revocation preserves grant fields and ownership while recording the revoker as controller.
The validation layers have different responsibilities:
- Envelope validation checks cryptography and payload shape, not principal authority.
- Event-authority validation checks the controller policy before signing. Acceptance validation also checks the envelope and authoritative-resolution URL.
- Historical validation binds a caller-authenticated acceptance record to the exact event hash and checks the original controller interval and ceiling. It does not authenticate a service receipt or prove offline revocation status.
- Use validation checks audience, status, and validity. Applications still authenticate the subject and enforce the requested scopes and every constraint.
Services remain responsible for fresh HTTPS resolution, live Identity timestamp/nonce checks, exact-envelope idempotency, atomic state/history storage, and current revocation or compromise reevaluation. Pass only authoritative documents, authenticated acceptance evidence, and trusted previous state. These are SDK building blocks, not a hosted delegation service.
# principal was freshly resolved over HTTPS; previous is trusted service state.
validate_delegation_acceptance(envelope, principal, resolved_url, accepted_at, previous)
credential = materialize_delegation_credential(
envelope, accepted_at=accepted_at, previous=previous,
)
validate_delegation_use(credential, "https://dmsg.net", now)
The same module exports Controller, DelegationPolicy, DelegationAcceptance, validate_controller, validate_controller_enumeration, and validate_historical_delegation. Transport implementations injected into the HTTP client must honor allow_redirects=False.
Running tests
From the repository root, use the same dependency extra and runner as CI:
python3 -m pip install -e './python/agent-protocols[test]'
python3 -m pytest python/agent-protocols/tests
The suite includes both unittest.TestCase classes and pytest functions. Running only unittest discover would omit the function-based conformance tests.
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_protocols-0.8.0.tar.gz.
File metadata
- Download URL: agent_protocols-0.8.0.tar.gz
- Upload date:
- Size: 38.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
757de022b2bd6e34eb13a6237f6fc4a7c4ae092d1a22437fcf9b9b9f73fc409b
|
|
| MD5 |
80fea4672530f958bafdd0d06349ab55
|
|
| BLAKE2b-256 |
55fe13dd7dfe83242368b1d1c312dca9da55788217aa0fa516f9b7cc7b7843e7
|
File details
Details for the file agent_protocols-0.8.0-py3-none-any.whl.
File metadata
- Download URL: agent_protocols-0.8.0-py3-none-any.whl
- Upload date:
- Size: 24.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c195293b3db969b968af93c674de9708a0b80e6499ec0d566dac4accdc9c303
|
|
| MD5 |
683589ee8ec5130d621a74f5441a66ae
|
|
| BLAKE2b-256 |
e08d416efdd2764a5fb324da9da0d2e920a61a9844621470b90e1ae43aded247
|