Skip to main content
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

Methods

How a run works

  1. run() generates the initial paths.
  2. In each of max_loops iterations, every path is simulated. A path that scores below 0.7 gets a meta-reflection and is replaced by its revised paths. A path that scores 0.7 or higher is kept.
  3. The model selects the most promising of the resulting paths, which become the next iteration’s paths.
  4. After the last iteration, the model synthesizes a solution from the selected paths and every path seen before.
Every step goes through one internal Agent and appends its reply to agent.conversation. The conversation holds the model’s replies but not the task. It is not cleared between calls, so a second run() returns the first run’s messages too.
The model call count grows with the number of paths: each iteration makes one simulation call per path, plus a reflection and a revision call for each path below 0.7. A reply with many lines produces many paths, so start with a small max_loops.

Example