Skip to main content

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

Metadata

Release files for a2p-sdk 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for a2p-sdk 0.1.3
File Size Uploaded
a2p_sdk-0.1.3.tar.gz 46.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for a2p-sdk 0.1.3
File Interpreter ABI Platform
a2p_sdk-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 79.1 kB

Release files / a2p_sdk-0.1.3.tar.gz

Download URL a2p_sdk-0.1.3.tar.gz
Size 46.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2f11272d2ba3fd90a4f42bf6a13883ce15c38c6fb4f707bcbbd2dcff921a8e4e
BLAKE2b-256 checksum
How to use checksums
cd332fd4c964cdd502f5b8f98d5d73b5fa9ae650a9498104235e91382b9c1d94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 29, 2026.

Transparency log

Release files / a2p_sdk-0.1.3-py3-none-any.whl

Download URL a2p_sdk-0.1.3-py3-none-any.whl
Size 32.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c3d03f9352e1fe37004d21db7d4d303c1820883b817b3f6da7b8cdac9eb3033d
BLAKE2b-256 checksum
How to use checksums
b75397e071b8bd02fbf306527e57542a001d126f3ab44dae72063bfec89f6f9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 29, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page