any_agent2agent
any_agent2agent now focuses on a single goal: normalize Agent2Agent (A2A) /
Agent Protocol communication so any application can talk to any remote agent
without learning a custom payload shape.
What's included
- AgentProtocolAdapter – HTTP client that speaks
/v1/exchangein the Agent Protocol format. - Server helpers –
create_lambda_handler,create_fastapi_router, and friends withprotocol="agent_protocol"so you can expose an agent quickly. FastAPI/Flask helpers auto-register themselves on an existingappwhen detected, so you rarely need to spin up a new server. - Bedrock tool helper –
create_bedrock_tool_handlerconverts any agent into an AWS Bedrock Agent tool/action group payload. - Shared models –
AgentMessage,BaseAgent, and a registry-backedAgentFactoryso future adapters can be re‑added without redesigning the package. - Schema registry loader – fetch schema manifests from GitHub/S3/local paths and auto-wire schema adapters for apps that need bespoke payloads.
- Secrets-aware config –
ConfigManagerfetches configuration values from AWS Secrets Manager or environment variables, used by the examples to drive ports and API keys. - Lean tests & workflows – only the pieces that validate the Agent Protocol surface remain.
If you need to add more adapters later, the factory, base classes, and docs
under docs/ADDING_PROVIDERS.md describe how to plug them back in.
Installation
pip install .
# or
pip install -e .[dev]
Quick start
Call a remote Agent Protocol service
from any_agent2agent import AgentFactory
agent = AgentFactory.create(
"agent_protocol",
base_url="https://agent.example.com",
api_key="optional-bearer-token",
)
response = agent.send("Draft a Jira rollout plan")
print(response.content)
print(response.metadata)
Expose your agent with Agent Protocol schema
from typing import List
from fastapi import FastAPI
from any_agent2agent import AgentMessage
from any_agent2agent.server import (
create_fastapi_router,
create_lambda_handler,
)
def integrations_agent(messages: List[AgentMessage]) -> str:
prompt = messages[-1].content
return f"Answering integrations question: {prompt}"
lambda_handler = create_lambda_handler(
integrations_agent,
protocol="agent_protocol",
default_metadata={"agent": "integrations"},
)
# FastAPI auto-registration detects the existing `app` variable.
app = FastAPI()
router = create_fastapi_router(
integrations_agent,
protocol="agent_protocol",
route_path="/agent/exchange",
)
if not getattr(router, "_a2a_auto_registered", False):
app.include_router(router)
The same protocol="agent_protocol" flag works with the FastAPI and Flask
helpers so you can expose /agent/exchange over HTTP.
Need streaming output? Enable it on the server helper and hit /stream:
router = create_fastapi_router(
integrations_agent,
protocol="agent_protocol",
streaming=True,
)
# POST /agent/stream returns newline-delimited JSON chunks
# Example client flag:
# {"messages": [...], "stream": true}
Lambda handlers can also opt-in:
lambda_handler = create_lambda_handler(
integrations_agent,
protocol="agent_protocol",
streaming=True,
)
stream_response = lambda_handler({"messages": [...], "stream": True}, None)
Wire agents into Bedrock tools
from any_agent2agent import AgentMessage, create_bedrock_tool_handler
def integrations_agent(messages: list[AgentMessage]):
yield "Checking integrations..."
yield ("Slack is ready ✅", {"agent": "integrations"})
bedrock_handler = create_bedrock_tool_handler(
integrations_agent,
protocol="agent_protocol",
)
# Bedrock Lambda/action-group event
event = {
"sessionId": "abc",
"inputText": "Enable Slack",
"stream": True,
}
response = bedrock_handler(event, None)
See docs/BEDROCK_TOOLING.md for the full contract plus configuration tips.
Bedrock bridge Lambda example
examples/bedrock_bridge_lambda.py demonstrates a deployable Lambda tool that
receives Bedrock events, fans out to the flight and hotel agents via Agent
Protocol, and returns a single combined message. Environment variables point the
bridge at any Agent Protocol service (FLIGHT_AGENT_BASE_URL,
HOTEL_AGENT_BASE_URL, etc.).
flowchart LR
Bedrock[Bedrock Agent] -->|inputText| BridgeLambda["Bedrock bridge Lambda"]
BridgeLambda -->|Agent Protocol| FlightAgent["Flight agent"]
BridgeLambda -->|Agent Protocol| HotelAgent["Hotel agent"]
FlightAgent -->|messages| BridgeLambda
HotelAgent -->|messages| BridgeLambda
BridgeLambda -->|responseBody.TEXT| Bedrock
Copy the example, zip it with your dependencies, and register the Lambda as an
action group in Bedrock; the helper automatically formats the Bedrock tool
response and surface streaming chunks when stream=true.
Reuse an existing FastAPI/Flask server
When the SDK spots a module-level app/application (or you explicitly
provide one), it auto-registers the Agent Protocol endpoint:
create_fastapi_router(...)callsinclude_router(...).create_flask_handler(...)callsadd_url_rule(...).
Environment overrides:
A2A_FASTAPI_APP=package.module:appforces a specific FastAPI app.A2A_FLASK_APP=package.module:applicationforces a specific Flask app.- Set either variable to
skip,off,0, etc. to disable auto-detection.
If no app is found the helpers still return the router/handler, so you can register them manually (as before).
Configure the Agent Protocol server port
The examples/expose_agent_agentprotocol.py FastAPI app reads its port from
AGENT_PROTOCOL_PORT. Values come from AWS Secrets Manager when
AGENT_PROTOCOL_SECRET_NAME is set, otherwise they fall back to local
environment variables:
export AGENT_PROTOCOL_SECRET_NAME="a2a/server/config"
# secret JSON must include {"AGENT_PROTOCOL_PORT": "8005"}
python examples/expose_agent_agentprotocol.py
ConfigManager drives this behavior and is available for your own settings as
well:
from any_agent2agent.config import ConfigManager
config = ConfigManager(secret_name="a2a/server/config")
api_key = config.get("AGENT_PROTOCOL_API_KEY")
Multiple agents, same protocol
Instantiate as many AgentProtocolAdapter clients as you need—point them at
different base_url values or reuse the same remote agent from different apps.
AgentFactory keeps the registration hooks required for future adapter
expansion.
Docs & diagrams
AGENT_PROTOCOL_QUICKSTART.md– hands-on walkthrough for both client and server roles.AGENT_TO_AGENT_GUIDE.md– explains how users, A2A clients, and remote agents collaborate.docs/ARCHITECTURE.md– updated architecture diagram for the Agent Protocol–only build.docs/ADDING_PROVIDERS.md– how to add adapters back in usingBaseAgent+AgentFactory.docs/SCHEMA_REGISTRY.md– describe the schema manifest format and how to plug custom schemas into the SDK.
Running tests
pip install -r requirements-dev.txt
pytest -v
The suite now focuses on:
tests/test_agent_protocol_adapter.pytests/test_server.pytests/test_models.pytests/test_factory.pytests/test_config.py
GitHub Actions (.github/workflows/test.yml) runs these tests on every push and
pull request, and .github/workflows/agent_protocol_e2e.yml spins up the sample
FastAPI server to exercise the adapter end-to-end.
Extending later
Even though the repository now ships only the Agent Protocol adapter, the core
scaffolding (base classes, registry, config helpers, packaging) stays intact.
Follow docs/ADDING_PROVIDERS.md whenever you want to add another adapter,
register new providers with AgentFactory, and reintroduce their tests/docs
incrementally.
License
MIT – see LICENSE.
Metadata
Release files for any-agent2agent 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| any_agent2agent-0.0.2.tar.gz | 32.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| any_agent2agent-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 62.3 kB
Release files / any_agent2agent-0.0.2.tar.gz
| Download URL | any_agent2agent-0.0.2.tar.gz |
|---|---|
| Size | 32.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
56e2296b1976eaf3a267986132dce4979902d5f09bc4fd460d12d2bf9377a095
|
|
BLAKE2b-256 checksum How to use checksums |
cca81ffc9cf68c8be597013d71f23d3262cc1ae530bdff3dc20232d81654befc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / any_agent2agent-0.0.2-py3-none-any.whl
| Download URL | any_agent2agent-0.0.2-py3-none-any.whl |
|---|---|
| Size | 29.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bdcb690065925f67b316a30b8e50d3930d5a00af25129703a1de7436a6a8cc11
|
|
BLAKE2b-256 checksum How to use checksums |
510b4e3973d5320e2a0ff4e0e8c583839042189429983c92e70704caa8d66d09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Security for any-agent2agent 0.0.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.