Skip to main content
a2a_agent_as_team_member.py
"""
Example demonstrating how to use a remote A2A agent as a Team member.

This shows how to include agents from an A2A-compatible server as members
in a local Team, enabling cross-framework agent orchestration.

Prerequisites:
1. Install A2A SDK:
   pip install a2a-sdk

2. Start the A2A server:
   python cookbook/05_agent_os/remote/agno_a2a_server.py

   The server will run on http://localhost:7779

3. Set your OPENAI_API_KEY environment variable
"""

import asyncio

from agno.agent import Agent, RemoteAgent
from agno.models.openai import OpenAIResponses
from agno.team import Team

# ---------------------------------------------------------------------------
# Create Local Member
# ---------------------------------------------------------------------------

local_calculator = Agent(
    name="Calculator",
    role="You perform mathematical calculations and explain the steps.",
    model=OpenAIResponses(id="gpt-5-mini"),
    instructions=["Show your work step by step.", "Be precise with numbers."],
)

# ---------------------------------------------------------------------------
# Create Remote A2A Member
# ---------------------------------------------------------------------------

remote_researcher = RemoteAgent(
    base_url="http://localhost:7779/a2a/agents/researcher-agent-2",
    agent_id="researcher-agent-2",
    protocol="a2a",
    a2a_protocol="rest",
)

# ---------------------------------------------------------------------------
# Create Team with Local + A2A Members
# ---------------------------------------------------------------------------

research_team = Team(
    name="Cross-Framework Research Team",
    model=OpenAIResponses(id="gpt-5-mini"),
    members=[
        local_calculator,
        remote_researcher,
    ],
    instructions=[
        "You lead a cross-framework team.",
        "Delegate math questions to the Calculator.",
        "Delegate research questions to the remote Researcher.",
        "Synthesize responses from all members.",
    ],
    markdown=True,
    show_members_responses=True,
)

# ---------------------------------------------------------------------------
# Run
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    asyncio.run(
        research_team.aprint_response(
            "Research the Pythagorean theorem and calculate 3^2 + 4^2",
            stream=True,
        )
    )

Run the Example

1

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
2

Install dependencies

uv pip install -U agno openai
3

Export your OpenAI API key

export OPENAI_API_KEY="your_openai_api_key_here"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
4

Run the example

Save the code above as a2a_agent_as_team_member.py, then run:
python a2a_agent_as_team_member.py
Full source: cookbook/05_agent_os/remote/07_a2a_agent_as_team_member.py