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 Iterative Reflective Expansion (IRE) Algorithm is a sophisticated reasoning framework that employs iterative hypothesis generation, simulation, and refinement to solve complex problems. It leverages a multi-step approach where an AI agent generates initial solution paths, evaluates their effectiveness through simulation, reflects on errors, and dynamically revises reasoning strategies.

Architecture

Workflow

  1. Generate initial hypotheses
  2. Simulate paths
  3. Reflect on errors
  4. Revise paths
  5. Select promising paths
  6. Synthesize solution

Class: IterativeReflectiveExpansion

Parameters

ParameterTypeDefaultDescription
agentAgentNoneThe Swarms agent instance used to perform reasoning tasks
max_loopsint5Maximum number of loops for the reasoning process
return_listboolFalseIf True, returns the conversation as a list of messages
return_dictboolFalseIf True, returns the conversation as a dictionary
promptstrGENERAL_REASONING_AGENT_SYS_PROMPTThe system prompt for the agent

Methods

MethodDescription
generate_initial_hypothesesGenerates an initial set of reasoning hypotheses based on the problem input
simulate_pathSimulates a given reasoning path and evaluates its effectiveness
meta_reflectPerforms meta-cognitive reflection on the provided error information
revise_pathRevises the reasoning path based on the provided feedback
select_promising_pathsSelects the most promising reasoning paths from a list of candidates
synthesize_solutionSynthesizes a final solution from the promising paths and historical memory
runExecutes the Iterative Reflective Expansion process on the provided problem

Example

from swarms import IterativeReflectiveExpansion

agent = IterativeReflectiveExpansion(
    max_loops=3,
)

agent.run("What is the 40th prime number?")