Skip to main content

What is Coordinate Team mode

Coordinate mode introduces a leader agent that takes charge of the entire workflow. The leader analyzes all tasks, creates a strategic plan, and delegates work to team members using a sophisticated delegation system.

Usage

from upsonic import Agent, Task, Team

# Create specialized agents
data_analyst = Agent(
    model="anthropic/claude-sonnet-4-5",
    name="Data Analyst",
    role="Data Analysis Expert",
    goal="Analyze data and extract insights"
)

report_writer = Agent(
    model="anthropic/claude-sonnet-4-5",
    name="Report Writer",
    role="Business Report Specialist",
    goal="Create professional business reports"
)

# Create team with coordination
team = Team(
    agents=[data_analyst, report_writer],
    mode="coordinate",
    model="anthropic/claude-sonnet-4-5"  # Required for leader agent
)

# Define tasks
tasks = [
    Task(description="Analyze Q4 sales data and identify trends"),
    Task(description="Create executive summary of findings")
]

# Leader agent coordinates the team
result = team.print_do(tasks)
print(result)

Streaming with mixed Agent and Team entities

Stream the leader’s output. Only the leader is streamed; delegated member outputs are not streamed. A header (e.g. --- [Leader] Leader ---) appears before the stream.
from upsonic import Agent, Task, Team

data_analyst = Agent(
    model="anthropic/claude-sonnet-4-5",
    name="Data Analyst",
    role="Data Analysis Expert",
    goal="Analyze data and extract insights",
)

report_writer = Agent(
    model="anthropic/claude-sonnet-4-5",
    name="Report Writer",
    role="Business Report Specialist",
    goal="Create professional business reports",
)

report_team = Team(
    entities=[report_writer],
    mode="sequential",
    name="ReportTeam",
)

team = Team(
    entities=[data_analyst, report_team],
    mode="coordinate",
    model="anthropic/claude-sonnet-4-5",
)

tasks = [
    Task(description="Analyze Q4 sales data and identify trends"),
    Task(description="Create executive summary of findings"),
]

for chunk in team.stream(tasks):
    print(chunk, end="", flush=True)

Params

  • agents: List of Agent instances
  • mode: Set to "coordinate"
  • model: Required - Model provider for the leader agent
  • memory: Optional - Shared memory for team coordination
  • response_format: Optional, defaults to str