Skip to main content
RemoteAgent allows you to run agents that are hosted on a remote AgentOS instance. It provides the same interface as a local agent, making it easy to integrate remote agents into your applications or compose them into teams and workflows.

Installation

pip install agno

Basic Usage

from agno.agent import RemoteAgent

# Create a remote agent pointing to a remote AgentOS instance
agent = RemoteAgent(
    base_url="http://localhost:7777",
    agent_id="my-agent",
)

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

Parameters

ParameterTypeDefaultDescription
base_urlstrRequiredBase URL of the remote AgentOS instance (e.g., "http://localhost:7777")
agent_idstrRequiredID of the remote agent to execute
timeoutfloat60.0Request timeout in seconds
config_ttlfloat300.0Time-to-live for cached configuration in seconds

Properties

id

Returns the agent ID.
print(agent.id)  # "my-agent"

name

Returns the agent’s name from the remote configuration.
print(agent.name)  # "My Agent"

description

Returns the agent’s description from the remote configuration.
print(agent.description)  # "A helpful assistant agent"

role

Returns the agent’s role from the remote configuration.
print(agent.role)  # "assistant"

tools

Returns the agent’s tools as a list of dictionaries.
tools = agent.tools
if tools:
    for tool in tools:
        print(tool["name"])

db

Returns a RemoteDb instance if the agent has a database configured.
if agent.db:
    print(f"Database ID: {agent.db.id}")

knowledge

Returns a RemoteKnowledge instance if the agent has knowledge configured.
if agent.knowledge:
    print("Agent has knowledge enabled")

Methods

arun

Execute the remote agent asynchronously.
# Non-streaming
response = await agent.arun(
    "Tell me about Python",
    user_id="user-123",
    session_id="session-456",
)
print(response.content)

# Streaming
async for event in agent.arun(
    "Tell me a story",
    stream=True,
    user_id="user-123",
):
    if hasattr(event, "content") and event.content:
        print(event.content, end="", flush=True)
Parameters:
ParameterTypeDefaultDescription
inputstr | List | Dict | Message | BaseModelRequiredThe input message for the agent
streamboolFalseWhether to stream the response
user_idOptional[str]NoneUser ID for the run
session_idOptional[str]NoneSession ID for context persistence
session_stateOptional[Dict]NoneSession state dictionary
imagesOptional[Sequence[Image]]NoneImages to include
audioOptional[Sequence[Audio]]NoneAudio to include
videosOptional[Sequence[Video]]NoneVideos to include
filesOptional[Sequence[File]]NoneFiles to include
stream_eventsOptional[bool]NoneWhether to stream events
retriesOptional[int]NoneNumber of retries
knowledge_filtersOptional[Dict]NoneFilters for knowledge search
add_history_to_contextOptional[bool]NoneAdd history to context
dependenciesOptional[Dict]NoneDependencies dictionary
metadataOptional[Dict]NoneMetadata dictionary
auth_tokenOptional[str]NoneJWT token for authentication
Returns:
  • RunOutput when stream=False
  • AsyncIterator[RunOutputEvent] when stream=True

acontinue_run

Continue a paused agent run with tool results.
from agno.models.response import ToolExecution

response = await agent.acontinue_run(
    run_id="run-123",
    updated_tools=[
        ToolExecution(
            tool_call_id="call-1",
            result="Tool result here",
        )
    ],
)
Parameters:
ParameterTypeDefaultDescription
run_idstrRequiredID of the run to continue
updated_toolsList[ToolExecution]RequiredTool execution results
streamboolFalseWhether to stream the response
user_idOptional[str]NoneUser ID
session_idOptional[str]NoneSession ID
auth_tokenOptional[str]NoneJWT token for authentication
Returns:
  • RunOutput when stream=False
  • AsyncIterator[RunOutputEvent] when stream=True

cancel_run

Cancel a running agent execution.
success = await agent.cancel_run(run_id="run-123")
if success:
    print("Run cancelled")
Parameters:
ParameterTypeDefaultDescription
run_idstrRequiredID of the run to cancel
auth_tokenOptional[str]NoneJWT token for authentication
Returns: bool - True if successfully cancelled

get_agent_config

Get the agent configuration from the remote server (always fetches fresh).
config = await agent.get_agent_config()
print(f"Agent name: {config.name}")
print(f"Model: {config.model}")
Returns: AgentResponse

refresh_config

Force refresh the cached agent configuration.
config = agent.refresh_config()
Returns: AgentResponse

Using in Teams

Remote agents can be used as members of local teams:
from agno.agent import RemoteAgent
from agno.team import Team
from agno.models.openai import OpenAIChat

# Remote agent from another AgentOS instance
researcher = RemoteAgent(
    base_url="http://research-server:7777",
    agent_id="researcher-agent",
)

# Local team with remote agent member
team = Team(
    name="Research Team",
    model=OpenAIChat(id="gpt-4o"),
    members=[researcher],
    instructions="Coordinate research tasks",
)

response = await team.arun("Research AI trends")

Using in AgentOS Gateway

Remote agents can be registered in a local AgentOS to create a gateway:
from agno.agent import RemoteAgent
from agno.os import AgentOS

agent_os = AgentOS(
    agents=[
        RemoteAgent(base_url="http://server-1:7777", agent_id="agent-1"),
        RemoteAgent(base_url="http://server-2:7777", agent_id="agent-2"),
    ],
)
See AgentOS Gateway for more details.

Error Handling

from agno.exceptions import RemoteServerUnavailableError

try:
    response = await agent.arun("Hello")
except RemoteServerUnavailableError as e:
    print(f"Remote server unavailable: {e.message}")

Authentication

For authenticated AgentOS instances, pass the auth_token parameter:
response = await agent.arun(
    "Hello",
    auth_token="your-jwt-token",
)