Team class enables multiple agents to work together on complex tasks. Teams can operate in different modes, delegate work to members, and coordinate responses.
Constructor
Core Parameters
List of agents or teams that make up this team. Can also be a callable factory.
Language model for the team leader to use for coordination.
A descriptive name for the team.
Unique identifier for the team. Auto-generated if not provided.
If this team is part of another team, this is its role.
Execution Modes
Team execution mode. When set, overrides the boolean flags below.
If True, team leader won’t process member responses and returns them directly.
If True, delegates the task to all members instead of deciding which to use.
If False, sends the run input directly to member agents.
Maximum number of iterations for autonomous task loop (mode=tasks).
Session & State
Default session ID for the team.
Session state stored in the database.
If True, adds session_state to the context.
If True, gives the team tools to update session_state.
History & Memory
Send team-level history to members.
Number of historical runs to include in messages to members.
If True, sends all member interactions during current run to delegated members.
Adds messages from chat history to the context.
Number of historical runs to include.
Database
Database for storing team sessions and history.
Memory manager for the team.
Knowledge & Tools
Knowledge base for the team.
Tools available to the team leader.
If True, adds a tool to get information about team members.
If True, adds a tool to read the chat history.
Response Configuration
Pydantic model or JSON schema for structured output.
Stream the response from the team.
Stream intermediate steps.
Stream events from member agents.
Store member agent runs inside the team’s RunOutput.
Methods
run()
Run the team with a task.input(str | List | Dict | Message | BaseModel): The input taskstream(bool): Whether to stream the responsesession_id(str): Optional session IDuser_id(str): Optional user ID
TeamRunOutput or Iterator of events if streaming
arun()
Async version ofrun().