Skip to main content
A 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:
  1. The team receives user input
  2. A Team Leader analyzes the input and decides how to break it down into subtasks
  3. The Team Leader delegates specific tasks to appropriate team members
  4. Team members complete their assigned tasks and return their results
  5. 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.
There are various ways to manipulate the execution of a team. Some common questions are: Below are some examples of how to change the behaviour of how tasks are delegated to the members.

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 set respond_directly to True.
It can make sense to use this feature in combination with determine_input_for_members=False. This would effectively turn the team into a router that simply routes requests to the appropriate member, without the team leader processing the responses.
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 the input 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.
This feature is particularly useful when you have specialized agents with distinct expertise areas and want to automatically direct queries to the right specialist.
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 set delegate_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