Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.swarms.world/llms.txt

Use this file to discover all available pages before exploring further.

The ReasoningDuo class implements a dual-agent reasoning system that combines a reasoning agent and a main agent to provide well-thought-out responses to complex tasks. This architecture separates the reasoning process from the final response generation.

Architecture

Task Input → Reasoning Agent → Structured Analysis → Main Agent → Final Output

Parameters

ParameterTypeDefaultDescription
model_namestr"reasoning-agent-01"Name identifier for the reasoning agent
descriptionstr"A highly intelligent..."Description of the reasoning agent’s capabilities
model_nameslist[str]["claude-sonnet-4-6", "gpt-5.4"]Model names for reasoning and main agents
system_promptstr"You are a helpful..."System prompt for the main agent

Methods

MethodParametersReturnsDescription
runtask: strstrProcesses a single task through both agents
batched_runtasks: List[str]List[str]Processes multiple tasks sequentially

Quick Start

from swarms.agents.reasoning_duo import ReasoningDuo

duo = ReasoningDuo(
    model_name="reasoning-agent-01",
    model_names=["claude-sonnet-4-6", "gpt-5.4"]
)

result = duo.run("Explain the concept of gravitational waves")

Examples

Mathematical Analysis

duo = ReasoningDuo()

math_task = """
Solve the following differential equation:
dy/dx + 2y = x^2, y(0) = 1
"""

solution = duo.run(math_task)

Financial Analysis

finance_task = """
Calculate the Net Present Value (NPV) of a project with:
- Initial investment: $100,000
- Annual cash flows: $25,000 for 5 years
- Discount rate: 8%
"""

analysis = duo.run(finance_task)

Customizing Agent Behavior

duo = ReasoningDuo(
    model_name="custom-reasoning-agent",
    description="Specialized financial analysis agent",
    model_names=["claude-sonnet-4-6", "gpt-5.4"],
    system_prompt="You are a financial expert AI assistant..."
)

Batch Processing

tasks = [
    "Analyze market trends for tech stocks",
    "Calculate risk metrics for a portfolio",
    "Forecast revenue growth"
]

results = duo.batched_run(tasks)

Best Practices

  1. Task Formulation: Be specific and clear in task descriptions. Include relevant context and constraints.
  2. Performance Optimization: Use batched_run for multiple related tasks. Monitor agent outputs for consistency.
  3. Model Selection: Adjust model parameters based on task complexity.