ReasoningAgentRouter enables dynamic selection and execution of different reasoning strategies based on task requirements. It provides a flexible interface to work with multiple reasoning approaches.
Architecture
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
agent_name | str | "reasoning_agent" | Name identifier for the agent |
description | str | "A reasoning agent..." | Description of the agent’s capabilities |
model_name | str | "claude-sonnet-4-6" | The underlying language model to use |
system_prompt | str | "You are a helpful..." | System prompt for the agent |
max_loops | int | 1 | Maximum number of reasoning loops |
swarm_type | agent_types | "reasoning_duo" | Type of reasoning swarm to use |
num_samples | int | 1 | Number of samples for self-consistency |
output_type | OutputType | "dict-all-except-first" | Format of the output |
num_knowledge_items | int | 6 | Number of knowledge items for GKP agent |
memory_capacity | int | 6 | Memory capacity for agents that support it |
eval | bool | False | Enable evaluation mode for self-consistency |
random_models_on | bool | False | Enable random model selection for diversity |
majority_voting_prompt | Optional[str] | None | Custom prompt for majority voting |
reasoning_model_name | Optional[str] | "claude-3-5-sonnet-20240620" | Model for reasoning in ReasoningDuo |
Available Agent Types
The following values are supported for theswarm_type parameter:
"reasoning-duo"or"reasoning-agent""self-consistency"or"consistency-agent""ire"or"ire-agent""ReflexionAgent""GKPAgent""AgentJudge"
Methods
| Method | Description |
|---|---|
select_swarm() | Selects and initializes the appropriate reasoning swarm |
run(task, img?, **kwargs) | Executes the selected swarm’s reasoning process |
batched_run(tasks, imgs?, **kwargs) | Executes the reasoning process on a batch of tasks |
Examples
Basic Usage
Self-Consistency with Evaluation
ReasoningDuo with Image Support
GKP Agent
Reflexion Agent
Choosing the Right Type
| Scenario | Recommended Type | Why |
|---|---|---|
| Tasks requiring high reliability | self-consistency | Multiple validation paths, consensus building |
| Complex tasks needing analysis + action | reasoning-duo | Separates reasoning from execution |
| Problems requiring iterative refinement | ire | Designed for progressive improvement |
| Tasks requiring introspection | ReflexionAgent | Self-reflection and learning from experience |
| Knowledge-intensive tasks | GKPAgent | Generates knowledge before reasoning |
| Quality control | AgentJudge | Specialized evaluation capabilities |
Best Practices
- Swarm Type Selection: Match the reasoning strategy to your task requirements
- Performance: Adjust
max_loopsandnum_samplesbased on task complexity - Self-Consistency: Use 3-5 samples for most tasks, 7+ for critical decisions
- Multi-modal: Use vision-capable models when processing images
- ReasoningDuo: Set different models for reasoning vs execution via
reasoning_model_name