ReAct & Reflexion

Learn how interleaving reasoning with actions and self-reflection loops push model capabilities further.

8 min read
2 quiz questions

ReAct (Reasoning + Acting) is a prompting paradigm where the model alternates between thinking about what to do and taking actions (like searching, calculating, or calling tools). Instead of trying to answer from memory alone, ReAct lets models gather information dynamically and reason about what they find.

ReAct trace: Thought 1: I need to find the population of Tokyo and New York to compare them. Action 1: Search("Tokyo population 2024") Observation 1: Tokyo metro area population is approximately 37.4 million. Thought 2: Now I need New York's population. Action 2: Search("New York City population 2024") Observation 2: NYC metro area population is approximately 19.5 million. Thought 3: I can now compare. Tokyo is roughly 1.9x the population of NYC. Action 3: Finish("Tokyo's metro population (~37.4M) is nearly twice that of NYC (~19.5M).")

A ReAct prompt defines available actions and instructs the model to alternate between Thought, Action, and Observation steps. The key insight is that writing out reasoning before each action improves action selection, and seeing observations before further reasoning grounds the model in facts.

Reflexion extends ReAct by adding a self-critique loop. After the model produces an answer, it evaluates its own output, identifies errors or weaknesses, and generates an improved version. This can be repeated for multiple iterations. Reflexion has shown 10-20% improvements on coding and reasoning benchmarks.

Reflexion loop: 1. Attempt: Model generates solution to coding problem → fails 2 test cases 2. Reflect: "My solution doesn't handle edge case where input is empty. I also have an off-by-one error in the loop." 3. Retry: Model generates improved solution using reflection → passes all tests
Reflexion works best when you can provide concrete feedback (test results, error messages, factual corrections). Vague "try again" loops tend to produce diminishing returns after 2-3 iterations.

Prompt Templates

ReAct Reasoning Loop

Implements the ReAct pattern for grounded, tool-augmented reasoning.

Answer this question using a Thought → Action → Observation loop.

Available actions: Search(query), Calculate(expression), Finish(answer)

Question: [QUESTION]

Begin with Thought 1.

Reflexion Self-Critique

Applies Reflexion to improve quality through structured self-critique.

Task: [TASK]

Attempt 1: Produce your best solution.

Reflection: Critically evaluate your attempt. What errors, gaps, or weaknesses exist? Be specific.

Attempt 2: Using your reflection, produce an improved solution that addresses every issue you identified.

Test Your Knowledge

Knowledge Check

1 / 2

What makes ReAct different from standard chain-of-thought prompting?

Key Takeaways

  • ReAct interleaves reasoning with tool actions, grounding responses in real data rather than memory alone
  • Reflexion adds self-critique loops that can improve accuracy by 10-20% on complex tasks
  • Both patterns form the foundation of modern AI agent architectures