Skip to main content
The 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. The router builds a fresh agent of the selected type on every run() call, so no state carries over from one call to the next.
Tree of Thoughts is not a router type. Use TreeOfThoughts directly.

Architecture

Parameters

The constructor raises ReasoningAgentInitializationError when max_loops is 0, or when model_name or swarm_type is empty. An unknown swarm_type is not caught until run(), which then raises ReasoningAgentExecutorError. Both exceptions live in swarms.agents.reasoning_agent_router.

Available Agent Types

swarm_type accepts the values in the agent_types literal, which you can import with from swarms import agent_types. Each type receives only some of the router’s parameters: output_type has no effect on "ReflexionAgent", "GKPAgent" or "AgentJudge".
With "reasoning-duo", model_name reaches neither internal agent. The reasoning agent runs on reasoning_model_name, and the main agent always runs on ReasoningDuo’s default model, "gpt-5.4". To choose the main agent’s model, create ReasoningDuo directly and set model_names.
With "ire", the router passes num_samples, not max_loops, as the number of IRE iterations. With "AgentJudge", the router’s system_prompt replaces the judge’s built-in evaluation prompt, so pass a judging prompt.

Methods

Examples

Basic Usage

Self-Consistency with Evaluation

ReasoningDuo with Image Support

The reasoning agent runs on reasoning_model_name and the main agent on "gpt-5.4". Both must accept images.

GKP Agent

Reflexion Agent

IRE Agent

num_samples=2 runs two IRE iterations.

Choosing the Right Type

Best Practices

  1. Swarm Type Selection: Match the reasoning strategy to your task requirements
  2. Performance: Adjust max_loops and num_samples based on task complexity
  3. Self-Consistency: Use 3-5 samples for most tasks, 7+ for critical decisions
  4. Multi-modal: Use vision-capable models when processing images
  5. ReasoningDuo: Set the reasoning agent’s model with reasoning_model_name. To choose the main agent’s model too, use ReasoningDuo directly