jongkwan.dev
Development · Essay №036

ReAct (Reasoning + Acting)

Reasoning + Acting - a loop that thinks, uses a tool, and observes the result

Jongkwan Lee2026년 1월 29일5 min read
Contents

An agent pattern that cycles through Thought, Action, and Observation, reinforcing reasoning with external tools.

Concept

ReAct is an agent framework that combines reasoning and acting. It follows a loop: think, call an external tool, then observe the result.

How the loop works

  1. Thought -- analyze the current situation and plan the next step
  2. Action -- call an external tool (search, calculation, and so on)
  3. Observation -- receive the result of the action
  4. Repeat steps 1-3 until the goal is reached

Example

Question: "How tall is Lotte World Tower?"

Thought: I need the height of Lotte World Tower. A search is required. Action: [Search] "Lotte World Tower height" Observation: 554.5 meters

Thought: I have the information. I can answer. Answer: 554.5 meters

Multi-step reasoning example

Question: "What is the height difference between the tallest and second-tallest buildings in Korea?"

Thought: First I need to know the tallest building. Action: [Search] "tallest building in Korea" Observation: Lotte World Tower (554.5m)

Thought: I also need the second-tallest building. Action: [Search] "second tallest building in Korea" Observation: Haeundae LCT The Sharp (411.6m)

Thought: Now I can compute the difference. Action: [Calculate] 554.5 - 411.6 Observation: 142.9

Answer: 142.9 meters

Advantages

AdvantageDescription
VerifiabilityWhich tools were used is transparent
Current informationSearch gives access to real-time information
TransparencyThe reasoning process is explicit
ExtensibilityNew tools are easy to add

Problems Chain of Thought (CoT) alone cannot solve

Question: "What is the weather in Seoul today?"

CoT only: Thought: Seoul is the capital of Korea, and... Answer: Seoul has four distinct seasons... (hallucination)

With ReAct: Thought: I need real-time weather information Action: [Search] "Seoul weather today" Observation: Clear, temperature -2°C Answer: Seoul is clear today, with a temperature of -2 degrees Celsius.

Performance

ReAct is not always best on its own. On HotpotQA, which is reasoning-heavy, CoT does better, and ReAct performs best when combined with CoT Self-Consistency (CoT-SC). On FEVER, a fact-verification benchmark, ReAct beats CoT. The numbers below are the PaLM-540B results reported in the ReAct paper.

BenchmarkCoTReActReAct + CoT-SC
HotpotQA (EM, Exact Match)29.427.435.1
FEVER (accuracy)56.360.964.6

Which approach wins depends on the benchmark. Combining external observation (ReAct) with internal reasoning (CoT) covers the weaknesses of both.

Available tools

ToolPurposeExample
SearchInformation retrievalRecent news, fact checking
CalculateArithmeticComplex computations
WikipediaEncyclopedia lookupConcept explanations
CodeCode executionProgramming tasks
CalendarDate arithmeticDay of week, interval calculations

Limitations

  1. Failure on complex multi-step tool use

    • Errors increase as the tool call sequence gets more complicated
  2. Hard to recover from a wrong path

    • Once headed in the wrong direction, backing out is difficult
  3. Tool dependence

    • Without an appropriate tool, the problem cannot be solved

Combining with Reflexion

ReAct's limitations can be mitigated by combining it with Reflexion:

First attempt Thought: Let me search Action: [Search] "a poor query" Observation: Irrelevant results -- failure

Reflexion: "The query was too vague. I should search more specifically."

Second attempt Thought: Use a more specific query Action: [Search] "a specific query" Observation: Accurate results -- success

Implementation pattern

The react_loop function below implements ReAct's Thought-Action-Observation loop. The max_iterations parameter caps the number of iterations to prevent an infinite loop; the default of 5 is enough for most multi-step reasoning problems. On each iteration the LLM generates a Thought, decides an Action, and the corresponding tool ([Search], [Calculate], and so on) is executed. The resulting Observation accumulates in context, and once the goal is reached the final answer is returned.

python
def react_loop(question, max_iterations=5):
    context = f"Question: {question}\n"
 
    for i in range(max_iterations):
        # Generate a Thought
        thought = llm.generate(context + "Thought:")
        context += f"Thought: {thought}\n"
 
        # Decide an Action
        action = llm.generate(context + "Action:")
 
        if action.startswith("[Search]"):
            result = search(action.query)
        elif action.startswith("[Calculate]"):
            result = calculate(action.expression)
        else:
            break
 
        context += f"Action: {action}\n"
        context += f"Observation: {result}\n"
 
    # Generate the final answer
    answer = llm.generate(context + "Answer:")
    return answer
  • Chain of Thought (CoT): the underlying technique (reasoning only)
  • Reflexion: adds failure recovery
  • LATS: adds tree search
  • Toolformer: learns tool use automatically

Summary

ReAct is a pattern that cycles through Thought, Action, and Observation and reinforces reasoning with external tools. It fills in the real-time information and fact verification that reasoning alone cannot supply, and because the tools used are visible, the process is easy to verify. It does fail as tool call sequences get complicated, and recovering from a wrong path is hard. Reasoning-heavy problems favor CoT, while ReAct's advantage is largest on problems needing fact verification or current information. Reinforce it by combining with Reflexion when failure recovery is needed, or with LATS when search is needed.