Team.run() or Team.arun(). Here’s how they work:
- The team leader builds the context to send to the model (system message, user message, chat history, user memories, session state and other relevant inputs).
- The team leader sends this context to the model.
- The model processes the input and decides whether to use the
delegate_task_to_memberstool to delegate to team members, call other tools, or respond directly. - If delegation occurs, team members execute their tasks and return results to the team leader.
- The team leader processes the updated context and provides a final response.
- The team returns this final response to the caller.
Basic Execution
TheTeam.run() function runs the team and returns the output — either as a TeamRunOutput object or as a stream of TeamRunOutputEvent and RunOutputEvent (for member agents) objects (when stream=True). For example:
Run Output
TheTeam.run() function returns a TeamRunOutput object when not streaming. Here are some of the core attributes:
run_id: The id of the run.team_id: The id of the team.team_name: The name of the team.session_id: The id of the session.user_id: The id of the user.content: The response content.content_type: The type of content. In the case of structured output, this will be the class name of the pydantic model.reasoning_content: The reasoning content.messages: The list of messages sent to the model.metrics: The metrics of the run. For more details see Metrics.model: The model used for the run.member_responses: The list of member responses. Optional to add whenstore_member_responses=Trueon theTeam.
Team members inherit the
model from their parent team if no model is specified.
The reasoning_model, parser_model, and output_model must be explicitly set for each team or team member.
See the model inheritance example.Streaming
To enable streaming, setstream=True when calling run(). This will return an iterator of TeamRunOutputEvent objects instead of a single response.
Streaming all events
By default, when you stream a response, only theRunContent events will be streamed.
You can also stream all run events by setting stream_events=True.
This will provide real-time updates about the team’s internal processes, like tool calling or reasoning:
Handling Events
You can process events as they arrive by iterating over the response stream:Team member events are yielded during team execution when a team member is
being executed. You can disable this by setting
stream_member_events=False.Storing Events
You can store all the events that happened during a run on theRunOutput object.
TeamRunContentEvent and RunContentEvent events are not stored. You can modify which events are skipped by setting the events_to_skip parameter.
For example:
Event Types
The following events are sent by theTeam.run() and Team.arun() functions depending on team’s configuration:
Core Events
Tool Events
Reasoning Events
Memory Events
Session Summary Events
Pre-Hook Events
Post-Hook Events
Parser Model events
Output Model events
See detailed documentation in the TeamRunOutput documentation.
Custom Events
If you are using your own custom tools, it will often be useful to be able to yield custom events. Your custom events will be yielded together with the rest of the expected Agno events. We recommend creating your custom event class extending the built-inCustomEvent class:
Specify Run User and Session
You can specify which user and session to use when running the team by passing theuser_id and session_id parameters.
This ensures the current run is associated with the correct user and session. For example:
Passing Images / Audio / Video / Files
You can pass images, audio, video, or files to the team by passing theimages, audio, video, or files parameters. For example:
Cancelling a Run
A run can be cancelled by calling theTeam.cancel_run() method.
See more details in the Cancelling a Run documentation.
Developer Resources
- View the Team reference
- View the TeamRunOutput schema
- View Team Cookbook