Overview
TheMultiAgentRouter uses a boss agent powered by LLMs to intelligently route tasks to the most appropriate specialized agent(s). The boss agent analyzes task requirements and agent capabilities to make routing decisions, supporting both single and multiple agent assignments.
Installation
Attributes
str
default:"swarm-router"
The name of the router
str
A description of the router’s purpose
List[Agent]
default:"None"
A list of agents to be managed by the router
str
default:"gpt-5.4"
The model to use for the boss agent
float
default:"0.1"
The temperature for the boss agent’s model
A shared memory system for agents to query
OutputType
default:"dict"
The type of output expected from the agents
bool
default:"True"
Whether to print the boss agent’s decision
str
default:"None"
Custom system prompt for the router
bool
default:"True"
Whether to skip executing agents when their assigned task is null or None
Methods
route_task()
Routes a task to the appropriate agent(s) and returns their response.task(str): The task to be routed
run()
Alias for route_task().batch_run()
Batch route tasks to the appropriate agents sequentially.tasks(List[str]): List of tasks to route
concurrent_batch_run()
Concurrently route tasks to the appropriate agents.tasks(List[str]): List of tasks to route
Usage Examples
Basic Routing
Custom System Prompt
Batch Processing
Multiple Agent Assignment
Skip Null Tasks
Response Format
The boss agent returns routing decisions in this JSON format:Features
- Intelligent Routing: Boss agent analyzes task requirements and agent capabilities
- Single or Multiple Agents: Automatically determines if task requires one or multiple agents
- Custom Routing Logic: Override system prompt to customize routing behavior
- Batch Processing: Process multiple tasks sequentially or concurrently
- Flexible Output: Support for various output formats (dict, string, json, etc.)
- Null Task Handling: Option to skip agents with null/empty task assignments