Skip to content

A2A

The Agent2Agent (A2A) Protocol is the open standard for AI agent communication. Developed under the Linux Foundation, A2A makes it possible for agents to work together seamlessly across platforms, frameworks, and ecosystems.


  • BeeAI Framework installed with pip install beeai-framework
  • BeeAI Framework extension for A2A installed with pip install 'beeai-framework[a2a]'

The A2AAgent lets you easily connect with external agents using the A2A protocol.

import asyncio
import sys
import traceback
from beeai_framework.adapters.a2a.agents import A2AAgent, A2AAgentUpdateEvent
from beeai_framework.emitter import EventMeta
from beeai_framework.errors import FrameworkError
from beeai_framework.memory.unconstrained_memory import UnconstrainedMemory
from examples.helpers.io import ConsoleReader
async def main() -> None:
reader = ConsoleReader()
agent = A2AAgent(url="http://127.0.0.1:9999", memory=UnconstrainedMemory())
for prompt in reader:
# Run the agent and observe events
def print_update(data: A2AAgentUpdateEvent, event: EventMeta) -> None:
reader.write("Agent 🤖 (debug) : ", str(data.value))
response = await agent.run(prompt).on("update", print_update)
reader.write("Agent 🤖 : ", response.last_message.text)
if __name__ == "__main__":
try:
asyncio.run(main())
except FrameworkError as e:
traceback.print_exc()
sys.exit(e.explain())

A2AServer lets you expose agents built in the BeeAI framework via A2A protocol.

# pyrefly: ignore [missing-module-attribute]
from beeai_framework.adapters.a2a import A2AServer, A2AServerConfig
from beeai_framework.agents.requirement import RequirementAgent
from beeai_framework.backend import ChatModel
from beeai_framework.memory import UnconstrainedMemory
from beeai_framework.serve.utils import LRUMemoryManager
from beeai_framework.tools.search.duckduckgo import DuckDuckGoSearchTool
from beeai_framework.tools.weather import OpenMeteoTool
def main() -> None:
llm = ChatModel.from_name("ollama:granite4:micro")
agent = RequirementAgent(
llm=llm,
tools=[DuckDuckGoSearchTool(), OpenMeteoTool()],
memory=UnconstrainedMemory(),
)
# Register the agent with the A2A server and run the HTTP server
# For the ToolCallingAgent, we don't need to specify A2AAgent factory method
# because it is already registered in the A2AServer
# we use LRU memory manager to keep limited amount of sessions in the memory
A2AServer(
config=A2AServerConfig(port=9999, protocol="jsonrpc"), memory_manager=LRUMemoryManager(maxsize=100)
).register(agent, send_trajectory=True).serve()
if __name__ == "__main__":
main()

Agent execution (Python)

Pass execution=AgentExecutionConfig(...) to server.register() to configure max_iterations, total_max_retries, and max_retries_per_step for the built-in RequirementAgent, ToolCallingAgent, and ReActAgent. These options apply to every request served by that registration. Omitted fields and fields set to None retain the agent’s own defaults. The configuration is copied during registration, and non-empty execution configuration is rejected for other runnable types.

Protocol versions (Python)

The Python adapter is built on a2a-sdk 1.x. A2AServer also serves clients that still speak the 0.3 protocol, such as A2AAgent from earlier beeai-framework releases, while A2AServerConfig.enable_v0_3_compat is on (the default): the agent card lists the 0.3 interface too, and the 0.3 requests are accepted. Set it to False to serve 1.0 only. The agent card is served at /.well-known/agent-card.json; the deprecated /.well-known/agent.json path is no longer served. A2AAgent also works with agents that still serve 0.3.

Numbers in data parts and metadata travel as doubles, so whole numbers are returned as int, including values that were sent as floats (2.0 is returned as 2).