Remote Agent

Execute agents hosted on a remote AgentOS instance

The streaming loop prints only content events. Completed events can carry the full response again; handle completion and errors separately when building your application.

Create a Python file

remote_agent.py
import asyncio

from agno.agent import RemoteAgent
from agno.run.agent import RunEvent


async def remote_agent_example():
    """Call a remote agent hosted on another AgentOS instance."""
    agent = RemoteAgent(
        base_url="http://localhost:7778",
        agent_id="assistant-agent",
    )

    response = await agent.arun(
        "What is the capital of France?",
        user_id="user-123",
        session_id="session-456",
    )
    print(response.content)


async def remote_streaming_example():
    """Stream responses from a remote agent."""
    agent = RemoteAgent(
        base_url="http://localhost:7778",
        agent_id="assistant-agent",
    )

    async for chunk in agent.arun(
        "Tell me a short story about a brave knight",
        session_id="session-456",
        user_id="user-123",
        stream=True,
    ):
        if chunk.event == RunEvent.run_content and chunk.content:
            print(chunk.content, end="", flush=True)


if __name__ == "__main__":
    print("=" * 60)
    print("RemoteAgent Examples")
    print("=" * 60)

    print("\n1. Remote Agent Example:")
    asyncio.run(remote_agent_example())

    print("\n\n2. Remote Streaming Example:")
    asyncio.run(remote_streaming_example())

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U agno openai

Start an AgentOS Server

Follow the gateway remote-server recipe to save and run remote_server.py on port 7778. It registers assistant-agent and research-team; the gateway process is not needed here. Install the server dependencies and set OPENAI_API_KEY in that server's terminal.

Leave the server running. In another terminal, activate the client environment. The remote-only client does not need a provider API key.

Run the Client

python remote_agent.py