Agent Enrollment Protocol for Python
Official Python software development kit for the Agent Enrollment Protocol, the open protocol for Agent enrollment, Service-issued credentials, and authenticated Agent access.
Installation
python -m pip install agent-enrollment-protocol
Python 3.11 or newer is required. The distribution provides one typed package with modules for each integration role:
| Goal | Module |
|---|---|
| Use protocol models, validation, identity, and assertions | agent_enrollment_protocol.core |
| Inspect, enroll with, and authenticate to Services | agent_enrollment_protocol.agent |
| Integrate enrollment and authentication into a Service | agent_enrollment_protocol.service |
| Host managed Agent identities and delegated signing | agent_enrollment_protocol.platform |
Core is synchronous and transport-independent. Agent, Service, Platform, and their integration interfaces are asynchronous. Applications provide durable stores and security policy through typed protocols.
Framework integrations are optional and remain separate from Core and role behavior.
Runnable examples
The repository includes self-contained examples that exercise real signed protocol flows without external infrastructure:
uv run python examples/agent_service.py
uv run python examples/hosted_platform.py
The first example composes an Agent, Service, every built-in credential profile, protected resource,
and the framework-neutral ASGI adapter. The second demonstrates hosted identity Platform discovery,
Service DID resolution, provisioning, DID publication, delegated signing, and identity listing. See
examples/README.md for the integration boundaries and production
replacements.
The Service module includes stored credential profiles for each built-in Grant Type:
| Grant Type | Factory |
|---|---|
| API key | stored_api_key_grant_type() |
| Basic | stored_basic_grant_type() |
| OAuth Bearer | stored_oauth_bearer_grant_type() |
Each factory accepts application-owned credential issuance and storage implementations. The included memory store is intended for examples and local development.
Concrete Grant Types and extensions can define additional Grant and Revoke request members. Pass
those members through GrantOptions.parameters or RevokeOptions.parameters; the Agent retains
control of the standard Grant Type and Revoke selector fields.
Service ASGI integration
agent_enrollment_protocol.adapters provides a framework-neutral ASGI integration with no
additional dependency. AepAsgiApplication serves Inspect and every command advertised by the
Service. It enforces the command methods, media type, request-body limit, and idempotency header
boundary, and supplies cache metadata and conditional requests for Inspect.
AepAuthenticationMiddleware protects a downstream ASGI application and exposes the authenticated
Agent principal through principal_from_scope(). Place the protocol application outside the
authentication middleware so AEP's own command routes remain directly accessible:
from agent_enrollment_protocol.adapters import (
AepAsgiApplication,
AepAuthenticationMiddleware,
principal_from_scope,
)
protected_application = AepAuthenticationMiddleware(
application,
service,
resource_origin="https://service.example",
)
asgi_application = AepAsgiApplication(service, protected_application)
The downstream application can obtain its immutable principal from the ASGI scope:
principal = principal_from_scope(scope)
if principal is None:
raise RuntimeError("The route requires AEP authentication")
Use a separate unprotected application branch for public resources. For local development,
allow_insecure_loopback=True permits an HTTP localhost or loopback resource origin; production
origins require HTTPS.
Agent with a hosted identity Platform
PlatformIdentityProvider lets an Agent use a remote AEP Platform for Service-scoped identity
custody and delegated assertion signing. It discovers the Platform, recovers an existing active
identity before provisioning one, caches discovery metadata according to HTTP cache directives,
and supplies the resulting signer directly to Agent.
import os
from agent_enrollment_protocol.agent import (
Agent,
AgentOptions,
PlatformIdentityProvider,
PlatformIdentityProviderOptions,
)
async def authentication_headers() -> dict[str, str]:
return {"Authorization": f"Bearer {os.environ['AEP_PLATFORM_ACCESS_TOKEN']}"}
async with PlatformIdentityProvider(
PlatformIdentityProviderOptions(
authentication_headers=authentication_headers,
platform_url="https://platform.example",
)
) as identities:
async with Agent(AgentOptions(identity_provider=identities)) as agent:
result = await agent.service("https://service.example").enroll()
The Platform authentication callback is evaluated for each private request so applications can
refresh short-lived credentials. Supply pending_sign_resolver when the Platform can return
202 Accepted during delegated signing. The resolver receives the immutable retry interval and
opaque Platform context; returning updated context starts the next signing stage with a distinct
idempotency key. Without a resolver, pending signing raises PlatformSignPendingError for the
application to continue explicitly.
Hosted identity Platform
agent_enrollment_protocol.platform implements discovery, Service-scoped Agent identity
provisioning, DID document publication, identity listing and lifecycle, delegated signing, and
optional hosted verification.
Applications supply caller authorization, Service DID resolution, key custody, and durable stores. The included memory stores are suitable for local development, not production key custody or durable idempotency.
from datetime import timedelta
from agent_enrollment_protocol.core import SigningAlgorithm
from agent_enrollment_protocol.platform import DiscoveryOptions, Platform, PlatformOptions
platform = Platform(
PlatformOptions(
authorizer=authorizer,
did_host="platform.example",
did_url_template="https://platform.example/agents/{agent_did_id}/did.json",
discovery=DiscoveryOptions(
endpoint_base="/v1/aep",
lifecycle_endpoint="/v1/aep/agent-identities/{agent_identity_id}",
list_endpoint="/v1/aep/agent-identities",
platform_name="Example Platform",
provision_endpoint="/v1/aep/agent-identities",
sign_endpoint="/v1/aep/agent-identities/{agent_identity_id}/sign",
),
key_store=key_store,
maximum_lifetime=timedelta(minutes=5),
service_did_resolver=service_did_resolver,
signing_algorithms=(SigningAlgorithm.ES256,),
)
)
Map platform.discovery() to /.well-known/aep-platform and the remaining methods to the paths
advertised by DiscoveryOptions. Authenticate private Platform routes before constructing their
RequestContext; the Platform also invokes the supplied authorizer for every private operation.
Enable hosted verification only with a replay store.
Development
Install the locked development environment and run the complete merge gate:
uv sync --all-groups --locked
make verify
Run the shared Agent, Service, and Platform conformance suites against the public Python APIs:
make conformance
The command reads the adjacent ../aep-specs checkout by default and writes role reports to
.conformance/reports/. Set AEP_SPECS_DIR when the specifications are checked out elsewhere.
Run bidirectional Agent, Service, and Platform interoperability against the Node.js SDK:
make interoperability
The command reads the adjacent ../aep-node checkout by default and writes a four-row evidence
report to .interop/reports/aep-python-node-interoperability.json. Set AEP_NODE_DIR when the
Node.js SDK is checked out elsewhere.
See aep-specs for the normative drafts, schemas,
registries, examples, and test vectors.
Releases
Maintainers run the Release workflow from main. It verifies the package and a clean consumer,
runs shared conformance and Node.js interoperability, publishes through PyPI Trusted Publishing,
attests the distributions, and creates the matching tag and GitHub release with the verification
reports.
Security
See SECURITY.md for vulnerability reporting.
License
MIT.
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_enrollment_protocol-0.1.0.tar.gz.
File metadata
- Download URL: agent_enrollment_protocol-0.1.0.tar.gz
- Upload date:
- Size: 64.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f6670b7201e4000d26442cbf66ca3831f25078479d1bc945fdc5b1e9299e5b1
|
|
| MD5 |
383c762fc4110e43ecb2167e06e878de
|
|
| BLAKE2b-256 |
1609490cd7a17924069ad53e8b9beb6acc007a4c973d1e6b8231ef6cd8e9ee70
|
Provenance
The following attestation bundles were made for agent_enrollment_protocol-0.1.0.tar.gz:
Publisher:
release.yml on aep-foundation/aep-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_enrollment_protocol-0.1.0.tar.gz -
Subject digest:
6f6670b7201e4000d26442cbf66ca3831f25078479d1bc945fdc5b1e9299e5b1 - Sigstore transparency entry: 2706003500
- Sigstore integration time:
-
Permalink:
aep-foundation/aep-python@b23c04b04faece145f2e90c4c99d2ea18d3dc136 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/aep-foundation
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b23c04b04faece145f2e90c4c99d2ea18d3dc136 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file agent_enrollment_protocol-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agent_enrollment_protocol-0.1.0-py3-none-any.whl
- Upload date:
- Size: 78.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
340ddc52342d286f0c77b175bb55be7577906ecbec5ede4448eefd2e02d7acec
|
|
| MD5 |
5ccc9cde68b2b165320c5d4345233e2f
|
|
| BLAKE2b-256 |
08fb9ee9829f3e298797fbcaa3160a23ed97a60b09bd47d781bb51024069de3f
|
Provenance
The following attestation bundles were made for agent_enrollment_protocol-0.1.0-py3-none-any.whl:
Publisher:
release.yml on aep-foundation/aep-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_enrollment_protocol-0.1.0-py3-none-any.whl -
Subject digest:
340ddc52342d286f0c77b175bb55be7577906ecbec5ede4448eefd2e02d7acec - Sigstore transparency entry: 2706003667
- Sigstore integration time:
-
Permalink:
aep-foundation/aep-python@b23c04b04faece145f2e90c4c99d2ea18d3dc136 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/aep-foundation
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b23c04b04faece145f2e90c4c99d2ea18d3dc136 -
Trigger Event:
workflow_dispatch
-
Statement type: