Remote Workflow
Execute workflows hosted on a remote AgentOS server using async calls.
Demonstrates executing a workflow hosted on a remote server using RemoteWorkflow.
"""
Remote Workflow
===============
Demonstrates executing a workflow hosted on a remote server using `RemoteWorkflow`.
"""
import asyncio
import os
from agno.workflow import RemoteWorkflow
# ---------------------------------------------------------------------------
# Create Remote Workflow
# ---------------------------------------------------------------------------
remote_workflow = RemoteWorkflow(
base_url=os.getenv("AGNO_REMOTE_BASE_URL", "http://localhost:7777"),
workflow_id=os.getenv("AGNO_REMOTE_WORKFLOW_ID", "qa-workflow"),
)
async def run_remote_examples() -> None:
print("Remote workflow configuration")
print(f" Base URL: {remote_workflow.base_url}")
print(f" Workflow ID: {remote_workflow.id}")
try:
response = await remote_workflow.arun(
input="Summarize the latest progress in AI coding assistants.",
stream=False,
)
print("\nNon-streaming response preview")
print(f" Run ID: {response.run_id}")
print(f" Content: {str(response.content)[:240]}")
except Exception as exc:
print("\nRemote run failed.")
print(" Ensure AgentOS is running and the workflow ID exists.")
print(f" Error: {exc}")
return
try:
print("\nStreaming response preview")
stream = remote_workflow.arun(
input="List three practical use-cases for autonomous workflows.",
stream=True,
stream_events=True,
)
async for event in stream:
event_name = getattr(event, "event", type(event).__name__)
content = getattr(event, "content", None)
if content:
print(content, end="", flush=True)
elif event_name:
print(f"\n[{event_name}]")
print()
except Exception as exc:
print("\nStreaming run failed.")
print(f" Error: {exc}")
# ---------------------------------------------------------------------------
# Run Workflow
# ---------------------------------------------------------------------------
if __name__ == "__main__":
asyncio.run(run_remote_examples())Run the Example
Clone Agno
Clone the pinned Agno source and run the remaining commands from its root:
git clone https://github.com/agno-agi/agno.git
cd agno
git checkout v3.0.4Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U "agno[os]" openaiExport your API keys
export OPENAI_API_KEY="your_openai_api_key_here"Configure the remote workflow
In the first terminal, point the client at the companion server and its registered workflow. This local demo client sends no auth token; use a development shell without OS_SECURITY_KEY or JWT verification variables:
export AGNO_REMOTE_BASE_URL=http://localhost:7780
export AGNO_REMOTE_WORKFLOW_ID=qa-workflowStart the remote AgentOS
In a second terminal, change to the same cloned repository, activate its .venv, and export OPENAI_API_KEY there too. Start the server that registers qa-workflow:
python cookbook/05_agent_os/20_remote/servers/agentos_server.pyRun the example
Run the example from the repository root:
python cookbook/04_workflows/06_advanced_concepts/run_control/remote_workflow.pyFull source: cookbook/04_workflows/06_advanced_concepts/run_control/remote_workflow.py