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.

Architecture

Parameters

Available Agent Types

The following values are supported for the swarm_type parameter:
  • "reasoning-duo" or "reasoning-agent"
  • "self-consistency" or "consistency-agent"
  • "ire" or "ire-agent"_create_ire_agent passes max_loops=self.num_samples when building the underlying agent, so the router’s own max_loops is ignored for this type; num_samples controls the number of IRE iterations instead.
  • "ReflexionAgent"run() returns the raw list produced by ReflexionAgent.run() directly; it bypasses history_output_formatter, so output_type has no effect for this swarm type (every other type is formatted according to output_type).
  • "GKPAgent"
  • "AgentJudge"

Methods

Examples

Basic Usage

Self-Consistency with Evaluation

ReasoningDuo with Image Support

GKP Agent

Reflexion Agent

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 different models for reasoning vs execution via reasoning_model_name