Remote Agent as Team Member
Use a RemoteAgent as a team member.
Use a RemoteAgent as a team member. A RemoteAgent connects to an agent running on a remote AgentOS server, enabling distributed agent architectures.
"""
Remote Agent as Team Member
===========================
This cookbook demonstrates using a RemoteAgent as a team member.
A RemoteAgent connects to an agent running on a remote AgentOS server,
enabling distributed agent architectures.
Requirements:
- A running AgentOS server (e.g., `python -m agno.os --agents my_agent.py`)
- The remote agent must be registered on the server
Key Points:
- RemoteAgent only supports async methods (arun, aprint_response)
- Teams with RemoteAgent members MUST use async team methods
- Supports both AgentOS protocol and A2A (Agent-to-Agent) protocol
"""
import asyncio
from agno.agent import Agent
from agno.agent.remote import RemoteAgent
from agno.models.openai import OpenAIResponses
from agno.team.team import Team
async def main():
# 1. Create a local agent
summarizer = Agent(
name="Summarizer",
model=OpenAIResponses(id="gpt-5.6-luna"),
instructions="You summarize information concisely in 2-3 sentences.",
)
# 2. Create a RemoteAgent pointing to a remote AgentOS server
# Replace with your actual remote server URL and agent ID
remote_explorer = RemoteAgent(
base_url="http://localhost:7777", # Your AgentOS server URL
agent_id="explorer", # ID of the agent on the remote server
timeout=60.0, # Request timeout in seconds
)
# 3. Create a team with both local and remote agents
team = Team(
name="Hybrid Research Team",
model=OpenAIResponses(id="gpt-5.6-luna"),
members=[summarizer, remote_explorer],
instructions="""\
You are a research team leader. You have access to:
- Summarizer: Summarizes information concisely
- Explorer: Explores codebases and finds information (runs remotely)
Delegate code exploration tasks to Explorer, then have Summarizer condense the findings.""",
show_members_responses=True,
)
# 4. Use the team with async methods (required for RemoteAgent)
print("Testing hybrid team with remote agent...")
print("=" * 60)
await team.aprint_response(
"Use Explorer to find out what the main programming language is in the repo, "
"then have Summarizer give me a one-line summary.",
stream=True,
)
if __name__ == "__main__":
asyncio.run(main())Start the Explorer server
The cookbook's python -m agno.os --agents ... command is not an AgentOS entry point. Save this server as explorer_server.py and start it from the repository you want Explorer to inspect. Its ID and port match the client above.
from pathlib import Path
from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.os import AgentOS
from agno.tools.file import FileTools
explorer = Agent(
id="explorer",
name="Explorer",
model=OpenAIResponses(id="gpt-5.6-luna"),
tools=[FileTools(
base_dir=Path.cwd(),
enable_save_file=False,
enable_replace_file_chunk=False,
)],
instructions="Inspect the repository with your file tools and cite file paths.",
)
agent_os = AgentOS(agents=[explorer])
app = agent_os.get_app()
if __name__ == "__main__":
agent_os.serve(app=app, host="127.0.0.1", port=7777)After installing dependencies and exporting OPENAI_API_KEY, run python explorer_server.py in one terminal. Leave it running while you run basic_remote_member.py in another terminal with the same environment. The Explorer reads files on the server's machine. Use async team methods when a member is a RemoteAgent.
Run the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno openai fastapi uvicornExport your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"Run the example
Save the code above as basic_remote_member.py, then run:
python basic_remote_member.pyFull source: cookbook/03_teams/23_remote_agents/01_basic_remote_member.py