Toolkit for normalizing Agent Protocol (Agent2Agent) communication.
Project description
ai_agents_bridge
ai_agents_bridge 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. - 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 ai_agents_bridge 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 ai_agents_bridge import AgentMessage
from ai_agents_bridge.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.
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 ai_agents_bridge.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.
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 any_agent2agent-0.0.1.tar.gz.
File metadata
- Download URL: any_agent2agent-0.0.1.tar.gz
- Upload date:
- Size: 26.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da1aed6539d432449b7636b61f4987f30efad114b2f02728f9f1edbc3c72df18
|
|
| MD5 |
645ad332fb3f27eb43d953f36ee3329b
|
|
| BLAKE2b-256 |
b5e382ba5c15b7c0757294c8697f498257b768e53456e04d0155ec2975bb9b72
|
File details
Details for the file any_agent2agent-0.0.1-py3-none-any.whl.
File metadata
- Download URL: any_agent2agent-0.0.1-py3-none-any.whl
- Upload date:
- Size: 24.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32abe38141e8d041752121262800fed2427f7ff3040bff83ba7d02c619f131b8
|
|
| MD5 |
c6bc9472fd9aa2fcf37a1bb123791c13
|
|
| BLAKE2b-256 |
deb4429181821a9b5dcc50b705a8979e013a3425d3e2c5e24f96d53974ec7284
|