Redeo Docs
DocsLADR / Reflexion

Search Strategies

Reflexion

Reflexion

A draft-critique-refine loop bounded by the hop ceiling. The gate jumps backward on low scores to retry the draft with the critique in context.

Shape and when to use

Shape: draft followed by critique followed by a gate that jumps back to draft on low score followed by refine.

When to use: tasks with a verifiable correctness signal (math, code, logic, structured output). Reflexion works when the critique can identify concrete errors for the next draft pass to fix. Less useful for purely subjective tasks where "better" is not measurable.

Cost: 3 LLM calls per loop iteration multiplied by maxLoops. Bounded by the hop ceiling (default 200 hops, so up to ~66 reflexion iterations). In practice, set executionBudget.maxHops to bound iterations explicitly.

Config sketch

See Add Reflexion tutorial for the full ladder. The load-bearing piece is the gate's backward jump:

yaml
- id: critique
  if:
    jsonMatches:
      type: object
      required: [score]
      properties:
        score: { type: integer, minimum: 8 }
      additionalProperties: true
    then: continue
    else:
      jump: { stepId: draft }

When the critique's score is below 8, the engine repositions its step cursor back to draft. The next loop iteration's draft step can ingest the prior critique via loopRef: previous, giving the drafter the feedback to improve.

Termination

Reflexion loops terminate via one of:

  1. Gate passes. Score crosses the threshold; the gate's then: continue fires; the ladder advances past the critique step.
  2. Hop ceiling. Every loop iteration, jump, and recursion level counts as hops against the ladder's declared executionBudget.maxHops. When the ceiling is exceeded, the runtime publishes an error event with ceiling_exceeded: true and returns the best-so-far output.
  3. Spend ceiling. Same as hop ceiling, but triggered by maxSpend after an LLM call.

There is no static guarantee that reflexion converges. The runtime ceilings are the safety net. Always set executionBudget.maxHops to a value that bounds iterations to what your budget allows.

Common pitfalls

  • Reflexion on factual recall. "What is the capital of France?" does not improve from a critique step. The model either knows it or doesn't. Reflexion works on tasks where the model can identify and fix its own errors.
  • No critique feedback into the draft. If the next loop's draft step does not ingest the prior critique output (via loopRef: previous), the loop just retries the same draft. Always thread the critique back.
  • Threshold too high. If the gate's score threshold is unattainable, the loop burns the entire hop budget and exits with the last attempt. Calibrate the threshold empirically on a test set.