diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index db0a8e83..cc179dfa 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -250,6 +250,7 @@ nav: - Integrating External Agents from Griptape, Langchain, etc: "swarms/agents/external_party_agents.md" - Reasoning Agents: + - Overview: "swarms/agents/reasoning_agents_overview.md" - Self Consistency Agent: "swarms/agents/consistency_agent.md" - IRE Agent: "swarms/agents/iterative_agent.md" - Reasoning Duo: "swarms/agents/reasoning_duo.md" diff --git a/docs/swarms/agents/reasoning_agents_overview.md b/docs/swarms/agents/reasoning_agents_overview.md new file mode 100644 index 00000000..d995806b --- /dev/null +++ b/docs/swarms/agents/reasoning_agents_overview.md @@ -0,0 +1,389 @@ +# Reasoning Agents Overview + + +Reasoning agents are sophisticated agents that employ advanced cognitive strategies to improve problem-solving performance beyond standard language model capabilities. Unlike traditional prompt-based approaches, reasoning agents implement structured methodologies that enable them to think more systematically, self-reflect, collaborate, and iteratively refine their responses. + +These agents are inspired by cognitive science and human reasoning processes, incorporating techniques such as: + +- **Multi-step reasoning**: Breaking down complex problems into manageable components + +- **Self-reflection**: Evaluating and critiquing their own outputs + +- **Iterative refinement**: Progressively improving solutions through multiple iterations + +- **Collaborative thinking**: Using multiple reasoning pathways or agent perspectives + +- **Memory integration**: Learning from past experiences and building knowledge over time + +- **Meta-cognitive awareness**: Understanding their own thinking processes and limitations + + + +## Available Reasoning Agents + +| Agent Name | Type | Research Paper | Key Features | Best Use Cases | Implementation | Documentation | +|------------|------|----------------|---------------|----------------|----------------|---------------| +| **Self-Consistency Agent** | Consensus-based | [Self-Consistency Improves Chain of Thought Reasoning](https://arxiv.org/abs/2203.07870) (Wang et al., 2022) | • Multiple independent reasoning paths
• Majority voting aggregation
• Concurrent execution
• Validation mode | • Mathematical problem solving
• High-accuracy requirements
• Decision making scenarios
• Answer validation | `SelfConsistencyAgent` | [Guide](consistency_agent.md) | +| **Reasoning Duo** | Collaborative | Novel dual-agent architecture | • Separate reasoning and execution agents
• Collaborative problem solving
• Task decomposition
• Cross-validation | • Complex analysis tasks
• Multi-step problem solving
• Tasks requiring verification
• Research and planning | `ReasoningDuo` | [Guide](reasoning_duo.md) | +| **IRE Agent** | Iterative | Iterative Reflective Expansion framework | • Hypothesis generation
• Path simulation
• Error reflection
• Dynamic revision | • Complex reasoning tasks
• Research problems
• Learning scenarios
• Strategy development | `IterativeReflectiveExpansion` | [Guide](iterative_agent.md) | +| **Reflexion Agent** | Self-reflective | [Reflexion: Language Agents with Verbal Reinforcement Learning](https://arxiv.org/abs/2303.11366) (Shinn et al., 2023) | • Self-evaluation
• Experience memory
• Adaptive improvement
• Learning from failures | • Continuous improvement tasks
• Long-term projects
• Learning scenarios
• Quality refinement | `ReflexionAgent` | [Guide](reflexion_agent.md) | +| **GKP Agent** | Knowledge-based | [Generated Knowledge Prompting](https://arxiv.org/abs/2110.08387) (Liu et al., 2022) | • Knowledge generation
• Multi-perspective reasoning
• Information synthesis
• Fact integration | • Knowledge-intensive tasks
• Research questions
• Fact-based reasoning
• Information synthesis | `GKPAgent` | [Guide](gkp_agent.md) | +| **Agent Judge** | Evaluation | [Agent-as-a-Judge: Evaluate Agents with Agents](https://arxiv.org/abs/2410.10934) | • Quality assessment
• Structured evaluation
• Performance metrics
• Feedback generation | • Quality control
• Output evaluation
• Performance assessment
• Model comparison | `AgentJudge` | [Guide](agent_judge.md) | +| **REACT Agent** | Action-based | [ReAct: Synergizing Reasoning and Acting](https://arxiv.org/abs/2210.03629) (Yao et al., 2022) | • Reason-Act-Observe cycle
• Memory integration
• Action planning
• Experience building | • Interactive tasks
• Tool usage scenarios
• Planning problems
• Learning environments | `ReactAgent` | [Guide](react_agent.md) | + +## Agent Architectures + +### Self-Consistency Agent + +**Description**: Implements multiple independent reasoning paths with consensus-building to improve response reliability and accuracy through majority voting mechanisms. + +**Key Features**: +- Concurrent execution of multiple reasoning instances +- AI-powered aggregation and consensus analysis +- Validation mode for answer verification +- Configurable sample sizes and output formats + +**Architecture Diagram**: + +```mermaid +graph TD + A[Task Input] --> B[Agent Pool] + B --> C[Response 1] + B --> D[Response 2] + B --> E[Response 3] + B --> F[Response N] + C --> G[Aggregation Agent] + D --> G + E --> G + F --> G + G --> H[Majority Voting Analysis] + H --> I[Consensus Evaluation] + I --> J[Final Answer] + + style A fill:#e1f5fe + style J fill:#c8e6c9 + style G fill:#fff3e0 +``` + +**Use Cases**: Mathematical problem solving, high-stakes decision making, answer validation, quality assurance processes + +**Implementation**: `SelfConsistencyAgent` + +**Documentation**: [Self-Consistency Agent Guide](consistency_agent.md) + +--- + +### Reasoning Duo + +**Description**: Dual-agent collaborative system that separates reasoning and execution phases, enabling specialized analysis and task completion through coordinated agent interaction. + +**Key Features**: +- Separate reasoning and execution agents +- Collaborative problem decomposition +- Cross-validation between agents +- Configurable model selection for each agent + +**Architecture Diagram**: + +```mermaid +graph TD + A[Task Input] --> B[Reasoning Agent] + B --> C[Deep Analysis] + C --> D[Strategy Planning] + D --> E[Reasoning Output] + E --> F[Main Agent] + F --> G[Task Execution] + G --> H[Response Generation] + H --> I[Final Output] + + style A fill:#e1f5fe + style B fill:#f3e5f5 + style F fill:#e8f5e8 + style I fill:#c8e6c9 +``` + +**Use Cases**: Complex analysis tasks, multi-step problem solving, research and planning, verification workflows + +**Implementation**: `ReasoningDuo` + +**Documentation**: [Reasoning Duo Guide](reasoning_duo.md) + +--- + +### IRE Agent (Iterative Reflective Expansion) + +**Description**: Sophisticated reasoning framework employing iterative hypothesis generation, simulation, and refinement through continuous cycles of testing and meta-cognitive reflection. + +**Key Features**: +- Hypothesis generation and testing +- Path simulation and evaluation +- Meta-cognitive reflection capabilities +- Dynamic strategy revision based on feedback + +**Architecture Diagram**: + +```mermaid +graph TD + A[Problem Input] --> B[Hypothesis Generation] + B --> C[Path Simulation] + C --> D[Outcome Evaluation] + D --> E{Satisfactory?} + E -->|No| F[Meta-Cognitive Reflection] + F --> G[Path Revision] + G --> H[Knowledge Integration] + H --> C + E -->|Yes| I[Solution Synthesis] + I --> J[Final Answer] + + style A fill:#e1f5fe + style F fill:#fff3e0 + style J fill:#c8e6c9 +``` + +**Use Cases**: Complex reasoning tasks, research problems, strategy development, iterative learning scenarios + +**Implementation**: `IterativeReflectiveExpansion` + +**Documentation**: [IRE Agent Guide](iterative_agent.md) + +--- + +### Reflexion Agent + +**Description**: Advanced self-reflective system implementing actor-evaluator-reflector architecture for continuous improvement through experience-based learning and memory integration. + +**Key Features**: +- Actor-evaluator-reflector sub-agent architecture +- Self-evaluation and quality assessment +- Experience memory and learning capabilities +- Adaptive improvement through reflection + +**Architecture Diagram**: + +```mermaid +graph TD + A[Task Input] --> B[Actor Agent] + B --> C[Initial Response] + C --> D[Evaluator Agent] + D --> E[Quality Assessment] + E --> F[Performance Score] + F --> G[Reflector Agent] + G --> H[Self-Reflection] + H --> I[Experience Memory] + I --> J{Max Iterations?} + J -->|No| K[Refined Response] + K --> D + J -->|Yes| L[Final Response] + + style A fill:#e1f5fe + style B fill:#e8f5e8 + style D fill:#fff3e0 + style G fill:#f3e5f5 + style L fill:#c8e6c9 +``` + +**Use Cases**: Continuous improvement tasks, long-term projects, adaptive learning, quality refinement processes + +**Implementation**: `ReflexionAgent` + +**Documentation**: [Reflexion Agent Guide](reflexion_agent.md) + +--- + +### GKP Agent (Generated Knowledge Prompting) + +**Description**: Knowledge-driven reasoning system that generates relevant information before answering queries, implementing multi-perspective analysis through coordinated knowledge synthesis. + +**Key Features**: +- Dynamic knowledge generation +- Multi-perspective reasoning coordination +- Information synthesis and integration +- Configurable knowledge item generation + +**Architecture Diagram**: + +```mermaid +graph TD + A[Query Input] --> B[Knowledge Generator] + B --> C[Generate Knowledge Item 1] + B --> D[Generate Knowledge Item 2] + B --> E[Generate Knowledge Item N] + C --> F[Reasoner Agent] + D --> F + E --> F + F --> G[Knowledge Integration] + G --> H[Reasoning Process] + H --> I[Response Generation] + I --> J[Coordinator] + J --> K[Final Answer] + + style A fill:#e1f5fe + style B fill:#fff3e0 + style F fill:#e8f5e8 + style J fill:#f3e5f5 + style K fill:#c8e6c9 +``` + +**Use Cases**: Knowledge-intensive tasks, research questions, fact-based reasoning, information synthesis + +**Implementation**: `GKPAgent` + +**Documentation**: [GKP Agent Guide](gkp_agent.md) + +--- + +### Agent Judge + +**Description**: Specialized evaluation system for assessing agent outputs and system performance, providing structured feedback and quality metrics through comprehensive assessment frameworks. + +**Key Features**: +- Structured evaluation methodology +- Quality assessment and scoring +- Performance metrics generation +- Configurable evaluation criteria + +**Architecture Diagram**: + +```mermaid +graph TD + A[Output to Evaluate] --> B[Evaluation Criteria] + A --> C[Judge Agent] + B --> C + C --> D[Quality Analysis] + D --> E[Criteria Assessment] + E --> F[Scoring Framework] + F --> G[Feedback Generation] + G --> H[Evaluation Report] + + style A fill:#e1f5fe + style C fill:#fff3e0 + style H fill:#c8e6c9 +``` + +**Use Cases**: Quality control, output evaluation, performance assessment, model comparison + +**Implementation**: `AgentJudge` + +**Documentation**: [Agent Judge Guide](agent_judge.md) + +--- + +### REACT Agent (Reason-Act-Observe) + +**Description**: Action-oriented reasoning system implementing iterative reason-act-observe cycles with memory integration for interactive task completion and environmental adaptation. + +**Key Features**: +- Reason-Act-Observe cycle implementation +- Memory integration and experience building +- Action planning and execution +- Environmental state observation + +**Architecture Diagram**: + +```mermaid +graph TD + A[Task Input] --> B[Memory Review] + B --> C[Current State Observation] + C --> D[Reasoning Process] + D --> E[Action Planning] + E --> F[Action Execution] + F --> G[Outcome Observation] + G --> H[Experience Storage] + H --> I{Task Complete?} + I -->|No| C + I -->|Yes| J[Final Response] + + style A fill:#e1f5fe + style B fill:#f3e5f5 + style D fill:#fff3e0 + style J fill:#c8e6c9 +``` + +**Use Cases**: Interactive tasks, tool usage scenarios, planning problems, learning environments + +**Implementation**: `ReactAgent` + +**Documentation**: [REACT Agent Guide](react_agent.md) + + +## Implementation Guide + +### Unified Interface via Reasoning Agent Router + +The `ReasoningAgentRouter` provides a centralized interface for accessing all reasoning agent implementations: + +```python +from swarms.agents import ReasoningAgentRouter + +# Initialize router with specific reasoning strategy +router = ReasoningAgentRouter( + swarm_type="self-consistency", # Select reasoning methodology + model_name="gpt-4o-mini", + num_samples=5, # Configuration for consensus-based methods + max_loops=3 # Configuration for iterative methods +) + +# Execute reasoning process +result = router.run("Analyze the optimal solution for this complex business problem") +print(result) +``` + +### Direct Agent Implementation + +```python +from swarms.agents import SelfConsistencyAgent, ReasoningDuo, ReflexionAgent + +# Self-Consistency Agent for high-accuracy requirements +consistency_agent = SelfConsistencyAgent( + model_name="gpt-4o-mini", + num_samples=5 +) + +# Reasoning Duo for collaborative analysis workflows +duo_agent = ReasoningDuo( + model_names=["gpt-4o-mini", "gpt-4o"] +) + +# Reflexion Agent for adaptive learning scenarios +reflexion_agent = ReflexionAgent( + model_name="gpt-4o-mini", + max_loops=3, + memory_capacity=100 +) +``` + +## Choosing the Right Reasoning Agent + +| Scenario | Recommended Agent | Why? | +|----------|------------------|-------| +| **High-stakes decisions** | Self-Consistency | Multiple validation paths ensure reliability | +| **Complex research tasks** | Reasoning Duo + GKP | Collaboration + knowledge synthesis | +| **Learning & improvement** | Reflexion | Built-in self-improvement mechanisms | +| **Mathematical problems** | Self-Consistency | Proven effectiveness on logical reasoning | +| **Quality assessment** | Agent Judge | Specialized evaluation capabilities | +| **Interactive planning** | REACT | Action-oriented reasoning cycle | +| **Iterative refinement** | IRE | Designed for progressive improvement | + + +## Technical Documentation + +For comprehensive technical documentation on each reasoning agent implementation: + +- [Self-Consistency Agent](consistency_agent.md) + +- [Reasoning Duo](reasoning_duo.md) + +- [IRE Agent](iterative_agent.md) + +- [Reflexion Agent](reflexion_agent.md) + +- [GKP Agent](gkp_agent.md) + +- [Agent Judge](agent_judge.md) + +- [Reasoning Agent Router](reasoning_agent_router.md) + + +--- + +Reasoning agents represent a significant advancement in enterprise agent capabilities, implementing sophisticated cognitive architectures that deliver enhanced reliability, consistency, and performance compared to traditional language model implementations. \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 30d58aa0..8da6a778 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "swarms" -version = "8.0.0" +version = "8.0.1" description = "Swarms - TGSC" license = "MIT" authors = ["Kye Gomez "]