Running your Team
Learn how to run a team and get the response.
The Team.run()
function runs the team and generates a response, either as a TeamRunResponse
object or a stream of TeamRunResponseEvent
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.
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
.
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 the RunResponse
object.
By default the TeamRunResponseContentEvent
and RunResponseContentEvent
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 the Team.run()
and Team.arun()
functions depending on team’s configuration:
Core Events
Event Type | Description |
---|---|
TeamRunStarted | Indicates the start of a run |
TeamRunResponseContent | Contains the model’s response text as individual chunks |
TeamRunCompleted | Signals successful completion of the run |
TeamRunError | Indicates an error occurred during the run |
TeamRunCancelled | Signals that the run was cancelled |
Tool Events
Event Type | Description |
---|---|
TeamToolCallStarted | Indicates the start of a tool call |
TeamToolCallCompleted | Signals completion of a tool call, including tool call results |
Reasoning Events
Event Type | Description |
---|---|
TeamReasoningStarted | Indicates the start of the agent’s reasoning process |
TeamReasoningStep | Contains a single step in the reasoning process |
TeamReasoningCompleted | Signals completion of the reasoning process |
Memory Events
Event Type | Description |
---|---|
TeamMemoryUpdateStarted | Indicates that the agent is updating its memory |
TeamMemoryUpdateCompleted | Signals completion of a memory update |
See detailed documentation in the TeamRunResponse documentation.