Python SDK for the a2p (Agent 2 Profile) protocol
Project description
a2p-sdk
Python SDK for the a2p (Agent 2 Profile) protocol.
Installation
pip install a2p-sdk
# or
poetry add a2p-sdk
# or
uv add a2p-sdk
Quick Start
For Agent Developers
import asyncio
from a2p import A2PClient, create_agent_client
async def main():
# Create a client for your agent
client = create_agent_client(
agent_did="did:a2p:agent:my-assistant",
private_key=os.environ.get("A2P_PRIVATE_KEY"),
)
# Request access to a user's profile
profile = await client.get_profile(
user_did="did:a2p:user:alice",
scopes=["a2p:preferences", "a2p:interests"],
)
print(profile.get("common", {}).get("preferences", {}).get("communication"))
# Propose a new memory
await client.propose_memory(
user_did="did:a2p:user:alice",
content="Prefers TypeScript over JavaScript",
category="a2p:professional.preferences",
confidence=0.85,
context="User mentioned this during our conversation",
)
asyncio.run(main())
For Users
import asyncio
from a2p import A2PUserClient, create_user_client, SensitivityLevel
async def main():
# Create a user client
user = create_user_client()
# Create a new profile
profile = await user.create_profile(display_name="Alice")
# Add a memory manually
await user.add_memory(
content="I work as a software engineer at Acme Corp",
category="a2p:professional",
sensitivity=SensitivityLevel.STANDARD,
)
# Review pending proposals
proposals = user.get_pending_proposals()
for proposal in proposals:
print(f"{proposal.proposed_by['agentName']}: {proposal.memory.content}")
# Approve or reject
await user.approve_proposal(proposal.id)
# or: await user.reject_proposal(proposal.id, reason="Not accurate")
# Export your profile
json_str = user.export_profile()
asyncio.run(main())
Core Concepts
Profiles
A profile contains:
- Identity: DID, display name, pronouns
- Common: Shared preferences across all contexts
- Memories: Structured and episodic memories
- Sub-Profiles: Context-specific variations (work, personal, etc.)
- Access Policies: Who can access what
Scopes
Scopes control what data an agent can access:
from a2p import StandardScopes
# Common scopes
StandardScopes.PREFERENCES # 'a2p:preferences'
StandardScopes.INTERESTS # 'a2p:interests'
StandardScopes.PROFESSIONAL # 'a2p:professional'
StandardScopes.HEALTH # 'a2p:health' (sensitive)
Proposals
Agents can propose memories, but users must approve:
# Agent proposes
await client.propose_memory(
user_did="did:a2p:user:alice",
content="Likes jazz music",
category="a2p:interests.music",
confidence=0.75,
)
# User reviews
proposals = user.get_pending_proposals()
await user.approve_proposal(proposals[0].id)
API Reference
A2PClient (for agents)
| Method | Description |
|---|---|
get_profile(user_did, scopes, sub_profile?) |
Get filtered user profile |
propose_memory(user_did, content, ...) |
Propose a new memory |
check_permission(user_did, permission, scope?) |
Check if agent has permission |
set_agent_profile(profile) |
Set agent profile for trust evaluation |
A2PUserClient (for users)
| Method | Description |
|---|---|
create_profile(display_name?) |
Create a new profile |
load_profile(did) |
Load existing profile |
add_memory(content, ...) |
Add a memory manually |
get_pending_proposals() |
Get proposals awaiting review |
approve_proposal(id, ...) |
Approve a proposal |
reject_proposal(id, reason?) |
Reject a proposal |
export_profile() |
Export to JSON |
import_profile(json) |
Import from JSON |
License
EUPL-1.2
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 a2p_sdk-0.1.3.tar.gz.
File metadata
- Download URL: a2p_sdk-0.1.3.tar.gz
- Upload date:
- Size: 46.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f11272d2ba3fd90a4f42bf6a13883ce15c38c6fb4f707bcbbd2dcff921a8e4e
|
|
| MD5 |
5210b48e3a607ae1940a23b087e74e24
|
|
| BLAKE2b-256 |
cd332fd4c964cdd502f5b8f98d5d73b5fa9ae650a9498104235e91382b9c1d94
|
Provenance
The following attestation bundles were made for a2p_sdk-0.1.3.tar.gz:
Publisher:
release.yml on alpibrusl/a2p-protocol
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
a2p_sdk-0.1.3.tar.gz -
Subject digest:
2f11272d2ba3fd90a4f42bf6a13883ce15c38c6fb4f707bcbbd2dcff921a8e4e - Sigstore transparency entry: 870887308
- Sigstore integration time:
-
Permalink:
alpibrusl/a2p-protocol@b28b22fc115021e20ab415a3f10f6ae096748f9c -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/alpibrusl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b28b22fc115021e20ab415a3f10f6ae096748f9c -
Trigger Event:
push
-
Statement type:
File details
Details for the file a2p_sdk-0.1.3-py3-none-any.whl.
File metadata
- Download URL: a2p_sdk-0.1.3-py3-none-any.whl
- Upload date:
- Size: 32.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3d03f9352e1fe37004d21db7d4d303c1820883b817b3f6da7b8cdac9eb3033d
|
|
| MD5 |
0c3f49a576f234edcc85f4bb837ecb16
|
|
| BLAKE2b-256 |
b75397e071b8bd02fbf306527e57542a001d126f3ab44dae72063bfec89f6f9e
|
Provenance
The following attestation bundles were made for a2p_sdk-0.1.3-py3-none-any.whl:
Publisher:
release.yml on alpibrusl/a2p-protocol
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
a2p_sdk-0.1.3-py3-none-any.whl -
Subject digest:
c3d03f9352e1fe37004d21db7d4d303c1820883b817b3f6da7b8cdac9eb3033d - Sigstore transparency entry: 870887312
- Sigstore integration time:
-
Permalink:
alpibrusl/a2p-protocol@b28b22fc115021e20ab415a3f10f6ae096748f9c -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/alpibrusl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b28b22fc115021e20ab415a3f10f6ae096748f9c -
Trigger Event:
push
-
Statement type: