Team.run() (sync) or Team.arun() (async).
Basic Execution
Run the example
1
Set up your virtual environment
2
Install dependencies
3
Export your OpenAI API key
4
Run the example
Save the code as
running_team.py, then run:Execution Flow
When you callrun():
- Pre-hooks execute (if configured)
- Reasoning runs (if enabled) to plan the task
- Context is built with system message, history, memories, and session state
- Model decides whether to respond directly, use tools, or delegate to members
- Delegated members execute their tasks. Multiple async member calls can run concurrently.
- Leader completes the run by returning a routed member response or synthesizing member results, depending on the mode.
- Post-hooks execute (if configured)
- Session and metrics are stored (if database configured)
run_context and session_state. Async factories require arun() or aprint_response().
In
TeamMode.tasks, the leader uses task management tools to build and execute a shared task list, looping until the goal is complete or max_iterations is reached.
Teams can pause for human-in-the-loop requirements (e.g., approvals or user input). When a run requires confirmation, the run returns with pending requirements so you can collect input or resolve approvals before continuing.
Paused runs return status=RunStatus.paused and requirements on the TeamRunOutput.
Execution Flow Diagram
Execution Flow Diagram

Streaming
Enable streaming withstream=True. This returns an iterator of team events and can include delegated member events.
In
TeamMode.tasks, stream_events=True also emits TeamTaskCreated, TeamTaskUpdated, TeamTaskStateUpdated, TeamTaskIterationStarted, and TeamTaskIterationCompleted. See Task Mode Streaming Events.Stream All Events
Team content is streamed by default. Delegated member events are also forwarded becausestream_member_events=True by default. Set stream_events=True to include all team-level tool, reasoning, hook, and lifecycle events:
Stream Member Events
Delegated member events are forwarded by default. In async broadcast mode, member runs execute concurrently and their events can interleave. Setstream_member_events=False to suppress member events:
Run Output
Team.run() returns a TeamRunOutput object containing:
See TeamRunOutput reference for the full schema.
Async Execution
Usearun() for async execution. Members run concurrently when the leader delegates to multiple members at once.
Tasks Mode
Tasks mode runs an iterative loop that creates, executes, and updates tasks until the goal is complete ormax_iterations is reached.
Specifying User and Session
Associate runs with a user and session for history tracking:Passing Files
Pass images, audio, video, or files to the team:Structured Output
Pass an output schema to get structured responses:Cancelling Runs
Cancel a running team withTeam.cancel_run(). See Run Cancellation.
Print Response
For development, useprint_response() to display formatted output:
Background Execution
Run teams in the background witharun(background=True). Background execution requires a database so Agno can persist run state. With stream=True, Agno retains up to 10,000 events per run in memory for reconnection while the AgentOS process remains alive. After a disconnect, an AgentOS client calls the run’s /resume endpoint with the last received event index.
See Background Execution for polling, resumable streaming, and the /resume endpoint.
