Team internally has a team-leader “agent” that delegates tasks to the members. When you call run or arun on a team, the team leader agent uses a model to determine which member to delegate the task to.
The basic flow is:
- The team receives user input
- A Team Leader analyzes the input and decides how to break it down into subtasks
- The Team Leader delegates specific tasks to appropriate team members
- Team members complete their assigned tasks and return their results
- The Team Leader then either delegates to more team members, or synthesizes all outputs into a final, cohesive response to return to the user
Delegating to members is done by the team leader doing deciding to use a tool, namely the
delegate_task_to_members tool.This also means that when running the team asynchronously, i.e. when using arun, and the team leader decides to delegate to multiple members at once, these members will run concurrently.- How do I return the response of members directly? -> See the Members respond directly section.
- How do I send my user input directly to the members? -> See the Determine input for members section.
- How do I make sure the team leader delegates the task to all members? -> See the Delegate task to all members section.
Members respond directly
During normal team execution, the team leader will process the responses from the members and return a single response to the user. This is the default behaviour. If instead you want to return the response of members directly, you can setrespond_directly to True.
Below is an example of how to create a team that routes requests to the appropriate member based on the language of the user’s input.
respond_directly is not compatible with delegate_task_to_all_members.When using
respond_directly and the team leader decides to delegate the task to multiple members, the final content will be the results of all member responses concatenated together.Send input directly to members
When a team is run, by default the team leader will determine the “task” to give a specific member. This then becomes theinput when that member is run.
If you set determine_input_for_members to False, the team leader will send the user-provided input directly to the member agent(s). The team leader still determines the appropriate member to delegate the task to.
In the example below, we want to send stuctured pydantic input directly to the member agent. We don’t want the team leader to ingest this input and determine a task to give to the member agent.
Delegate tasks to all members simultaneously
When you setdelegate_task_to_all_members to True, the team leader will delegate the task to all members simultaneously, instead of one by one.When running asynchronously (using
arun), members will be executed concurrently.
More Examples
Basic Coordination
Basic team coordination pattern
Router Team
Router pattern with direct response
Cooperation Mode
Delegate tasks to all members for collaboration
Developer Resources
- View the Team reference
- View Cookbook