tasks mode via AgentOS. You can use the AgentOS API to send requests and test task streaming.
This example docstring contains a stale file path and an invalid JSON request to a removed
/v1/.../runs/stream route. Use the generated run and streaming steps below instead.team_tasks_streaming.py
"""Team Task Streaming Demo with AgentOS
This example demonstrates how to expose a Team running in `tasks` mode via AgentOS.
You can use the AgentOS API to send requests and test task streaming.
Usage:
uv run cookbook/05_agent_os/team_tasks_streaming.py
Then you can test streaming using curl:
curl -X POST http://0.0.0.0:7777/v1/teams/research-team/runs/stream \
-H "Content-Type: application/json" \
-d '{"message": "What are the key benefits of microservices architecture?"}'
"""
from agno.agent import Agent
from agno.db.postgres import PostgresDb
from agno.models.openai import OpenAIChat
from agno.os import AgentOS
from agno.team.mode import TeamMode
from agno.team.team import Team
# ---------------------------------------------------------------------------
# Create Database
# ---------------------------------------------------------------------------
db = PostgresDb(db_url="postgresql+psycopg://ai:ai@localhost:5532/ai")
# ---------------------------------------------------------------------------
# Create Members
# ---------------------------------------------------------------------------
researcher = Agent(
name="Researcher",
role="Researches topics and gathers information",
model=OpenAIChat(id="gpt-5-mini"),
db=db,
instructions=[
"Research the given topic thoroughly.",
"Provide factual information.",
],
)
summarizer = Agent(
name="Summarizer",
role="Summarizes information into concise points",
model=OpenAIChat(id="gpt-5-mini"),
db=db,
instructions=["Create clear, concise summaries.", "Highlight key points."],
)
# ---------------------------------------------------------------------------
# Create Team
# ---------------------------------------------------------------------------
team = Team(
id="research-team",
name="Research Team",
mode=TeamMode.tasks,
model=OpenAIChat(id="gpt-5-mini"),
members=[researcher, summarizer],
db=db,
instructions=[
"You are a research team leader. Follow these steps exactly:",
"1. Create ALL tasks for the Researcher to gather information.",
"2. Create ALL tasks for the Summarizer to summarize the research.",
"3. Execute the Researcher's task.",
"4. Execute the Summarizer's task.",
"5. Call mark_all_complete with a final summary when all tasks are done.",
],
max_iterations=3,
)
# ---------------------------------------------------------------------------
# AgentOS
# ---------------------------------------------------------------------------
agent_os = AgentOS(
name="Team Tasks Streaming Demo",
teams=[team],
)
app = agent_os.get_app()
# ---------------------------------------------------------------------------
# Run
# ---------------------------------------------------------------------------
if __name__ == "__main__":
agent_os.serve(app="team_tasks_streaming:app", port=7777, reload=True)
Run the Example
1
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
2
Install dependencies
uv pip install -U "agno[os]" "psycopg[binary]" openai
3
Export your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
4
Run PgVector
docker run -d \
-e POSTGRES_DB=ai \
-e POSTGRES_USER=ai \
-e POSTGRES_PASSWORD=ai \
-e PGDATA=/var/lib/postgresql \
-v pgvolume:/var/lib/postgresql \
-p 5532:5432 \
--name pgvector \
agnohq/pgvector:18
docker run -d `
-e POSTGRES_DB=ai `
-e POSTGRES_USER=ai `
-e POSTGRES_PASSWORD=ai `
-e PGDATA=/var/lib/postgresql `
-v pgvolume:/var/lib/postgresql `
-p 5532:5432 `
--name pgvector `
agnohq/pgvector:18
5
Start AgentOS
Save the code above as Keep the server running while you send the streaming request.
team_tasks_streaming.py, then run:python team_tasks_streaming.py
6
Test task streaming
In a second terminal, send form fields to the v2.7.2 team run endpoint:
curl -N -X POST http://localhost:7777/teams/research-team/runs \
-H "Accept: text/event-stream" \
-F "message=What are the key benefits of microservices architecture?" \
-F "stream=true"