Skip to main content

What is Route Team mode

Route mode uses an intelligent router agent to analyze incoming requests and select the single best specialist agent to handle the entire task. This is ideal for scenarios where you have domain experts and need to route queries efficiently.

Usage

from upsonic import Agent, Task, Team

# Create domain specialists
legal_expert = Agent(
    model="openai/gpt-4o",
    name="Legal Expert",
    role="Legal Advisor",
    goal="Provide legal guidance and compliance information",
    system_prompt="You are an expert in corporate law and regulations"
)

tech_expert = Agent(
    model="openai/gpt-4o",
    name="Tech Expert",
    role="Technology Specialist",
    goal="Provide technical solutions and architecture advice",
    system_prompt="You are an expert in software architecture and cloud systems"
)

# Create routing team
team = Team(
    agents=[legal_expert, tech_expert],
    mode="route",
    model="openai/gpt-4o"  # Required for router agent
)

# Router selects best expert
task = Task(description="What are the best practices for implementing OAuth 2.0?")
result = team.do(task)  # Automatically routed to tech_expert
print(result)

Params

  • agents: List of Agent instances
  • mode: Set to "route"
  • model: Required - Model provider for the router agent
  • response_format: Optional, defaults to str