Remote Agent

Execute agents hosted on remote AgentOS instances

RemoteAgent allows you to execute agents that are running on a remote AgentOS instance as if they were local agents. This enables distributed architectures where specialized agents run on different servers.

Prerequisites

Start the Remote Execution quickstart server, which registers assistant-agent on port 7778. Follow its server dependencies and model-key setup. Install uv pip install -U "agno[os]" in a separate client environment. The examples use the unauthenticated local server from that quickstart.

Basic Usage

import asyncio
from agno.agent import RemoteAgent

async def main():
    # Connect to a remote agent
    agent = RemoteAgent(
        base_url="http://localhost:7778",  # Running on localhost for this example
        agent_id="assistant-agent",
    )

    # Run the agent
    response = await agent.arun("What is the capital of France?")
    print(response.content)

asyncio.run(main())

Streaming Responses

Stream response content. The remaining snippets use await or async for; run them inside an async def function, as in Basic Usage:

from agno.agent import RemoteAgent

agent = RemoteAgent(
    base_url="http://localhost:7778",  # Running on localhost for this example
    agent_id="assistant-agent",
)

async for event in agent.arun(
    "Tell me a story about a brave knight",
    stream=True,
):
    if hasattr(event, "content") and event.content:
        print(event.content, end="", flush=True)

Configuration Access

Properties fetch metadata synchronously on a cache miss or after the default 300-second TTL expires. get_agent_config() fetches fresh configuration asynchronously. These wrapper metadata calls do not forward an auth_token; the example below requires metadata access without credentials. For protected metadata use AgentOSClient with explicit per-request headers.

from agno.agent import RemoteAgent

agent = RemoteAgent(
    base_url="http://localhost:7778",  # Running on localhost for this example
    agent_id="assistant-agent",
)

# Access cached properties
print(f"Name: {agent.name}")
print(f"Description: {agent.description}")
print(f"Tools: {agent.tools}")

# Get fresh configuration
config = await agent.get_agent_config()
print(f"Model: {config.model}")

# Force refresh cache
await agent.refresh_config()

Authentication

For a server configured with JWT authentication, pass its token per run. A static-security-key server accepts its OS_SECURITY_KEY value in the same parameter. This authenticates the run, not subsequent wrapper metadata requests:

from agno.agent import RemoteAgent

agent = RemoteAgent(
    base_url="http://localhost:7778",  # Running on localhost for this example
    agent_id="assistant-agent",
)

response = await agent.arun(
    "Hello",
    auth_token="your-jwt-token",
)

Error Handling

from agno.agent import RemoteAgent
from agno.exceptions import RemoteServerUnavailableError

agent = RemoteAgent(
    base_url="http://localhost:7778",  # Running on localhost for this example
    agent_id="assistant-agent",
)

try:
    response = await agent.arun("Hello")
except RemoteServerUnavailableError as e:
    print(f"Cannot connect to server: {e.message}")
    # Handle fallback logic

A2A Protocol Support

RemoteAgent supports compatible A2A HTTP REST and JSON-RPC endpoints. Set the binding explicitly when the remote server uses JSON-RPC. Available operations depend on the server; gRPC is not supported.

Connecting to Agno AgentOS via A2A interface

In the server terminal, install uv pip install -U "agno[a2a]", enable a2a_interface=True on the quickstart server's AgentOS, and restart it.

from agno.agent import RemoteAgent

agent = RemoteAgent(
    base_url="http://localhost:7778/a2a/agents/assistant-agent",  # Running on localhost for this example
    agent_id="assistant-agent",
    protocol="a2a",
    a2a_protocol="rest",  # Agno A2A servers use REST protocol by default
)

response = await agent.arun("Tell me an interesting fact")
print(response.content)

Connecting to Google ADK

This alternative assumes a separate Google ADK A2A server serving facts_agent over JSON-RPC on port 8001.

from agno.agent import RemoteAgent

# Connect to a Google ADK A2A server
agent = RemoteAgent(
    base_url="http://localhost:8001",  # Running on localhost for this example
    agent_id="facts_agent",
    protocol="a2a",
    a2a_protocol="json-rpc",  # Google ADK uses JSON-RPC
)

response = await agent.arun("Tell me an interesting fact")
print(response.content)

Developer Resources