The Team.run() function runs the team and generates a response, either as a TeamRunResponse object or a stream of TeamRunResponse objects.

Many of our examples use team.print_response() which is a helper utility to print the response in the terminal. It uses team.run() under the hood.

Here’s how to run your team. The response is captured in the response and response_stream variables.

from agno.team import Team
from agno.models.openai import OpenAIChat

agent_1 = Agent(name="News Agent", role="Get the latest news")

agent_2 = Agent(name="Weather Agent", role="Get the weather for the next 7 days")

team = Team(name="News and Weather Team", mode="coordinate", members=[agent_1, agent_2])

response = team.run("What is the weather in Tokyo?")

# Synchronous execution
result = team.run("What is the weather in Tokyo?")

# Asynchronous execution
result = await team.arun("What is the weather in Tokyo?")

# Streaming responses
for chunk in team.run("What is the weather in Tokyo?", stream=True):
    print(chunk.content, end="", flush=True)

# Asynchronous streaming
async for chunk in await team.arun("What is the weather in Tokyo?", stream=True):
    print(chunk.content, end="", flush=True)

Streaming Intermediate Steps

Throughout the execution of a team, multiple events take place, and we provide these events in real-time for enhanced team transparency.

You can enable streaming of intermediate steps by setting stream_intermediate_steps=True.

# Stream with intermediate steps
response_stream = team.run(
    "What is the weather in Tokyo?",
    stream=True,
    stream_intermediate_steps=True
)

Event Types

The following events are sent by the Team.run() and Team.arun() functions depending on team’s configuration:

Event TypeDescription
RunStartedIndicates the start of a run
RunResponseContains the model’s response text as individual chunks
RunCompletedSignals successful completion of the run
RunErrorIndicates an error occurred during the run
RunCancelledSignals that the run was cancelled
ToolCallStartedIndicates the start of a tool call
ToolCallCompletedSignals completion of a tool call. This also contains the tool call results.
ReasoningStartedIndicates the start of the agent’s reasoning process
ReasoningStepContains a single step in the reasoning process
ReasoningCompletedSignals completion of the reasoning process
UpdatingMemoryIndicates that the agent is updating its memory
WorkflowStartedIndicates the start of a workflow
WorkflowCompletedSignals completion of a workflow