Serve a Research Team over AG-UI

Mount an AgentOS Team on AG-UI so member tool calls and the coordinated final answer share one protocol event stream.

research_team.py
"""
Serve a Research Team over AG-UI
================================

Mount an AgentOS Team on AG-UI so member tool calls and the coordinated final
answer share one protocol event stream.

Prerequisites: OPENAI_API_KEY and internet access
Run: .venvs/demo/bin/python cookbook/05_agent_os/16_agui/research_team.py
Try: Request a sourced technology brief at http://localhost:7777/research-team/agui
"""

from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses
from agno.os import AgentOS
from agno.os.interfaces.agui import AGUI
from agno.team import Team
from agno.tools.websearch import WebSearchTools

# ---------------------------------------------------------------------------
# Create Research Team
# ---------------------------------------------------------------------------

db = SqliteDb(
    id="agui-research-team-db",
    db_file="tmp/agui_research_team.db",
)

researcher = Agent(
    id="agui-researcher",
    name="Researcher",
    role="Find current, relevant source material.",
    model=OpenAIResponses(id="gpt-5.5"),
    db=db,
    tools=[WebSearchTools()],
    instructions="Search the web, prefer primary sources, and return concise findings with URLs.",
)

writer = Agent(
    id="agui-writer",
    name="Writer",
    role="Turn research into a short, readable brief.",
    model=OpenAIResponses(id="gpt-5.5"),
    db=db,
    instructions="Synthesize supplied research without inventing unsupported facts.",
)

research_team = Team(
    id="agui-research-team",
    name="AG-UI Research Team",
    model=OpenAIResponses(id="gpt-5.5"),
    db=db,
    members=[researcher, writer],
    instructions=[
        "Delegate research to the Researcher and synthesis to the Writer.",
        "Return a concise brief with source links.",
    ],
    show_members_responses=True,
)

agent_os = AgentOS(
    id="agui-research-team-os",
    description="A coordinated research Team served through AG-UI.",
    teams=[research_team],
    interfaces=[AGUI(team=research_team, prefix="/research-team")],
)
app = agent_os.get_app()

# ---------------------------------------------------------------------------
# Run Research Team Server
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    agent_os.serve(app=app)

Run the Example

Set up your virtual environment

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

Install dependencies

uv pip install -U "agno[agui,os]" ddgs openai

Export your OpenAI API key

export OPENAI_API_KEY="your_openai_api_key_here"

Run the example

Save the code above as research_team.py, then run:

python research_team.py

Send a request

With the server running in another terminal:

Save this complete AG-UI request as agui-input.json. Replace content with the prompt for this example. Use a fresh runId for each run; keep threadId only when continuing the same session.

agui-input.json
{
  "threadId": "example-thread-1",
  "runId": "example-run-1",
  "state": {},
  "messages": [
    {"id": "example-message-1", "role": "user", "content": "Hello"}
  ],
  "tools": [],
  "context": [],
  "forwardedProps": {}
}

The endpoint accepts this object, rather than a JSON string or the REST run endpoint's message form field. The response is an SSE stream whose data values are AG-UI event objects. Inspect RUN_ERROR and RUN_FINISHED events; an HTTP 200 only establishes that the stream opened.

curl --no-buffer -H "Content-Type: application/json" --data-binary @agui-input.json http://localhost:7777/research-team/agui

Full source: cookbook/05_agent_os/16_agui/research_team.py