ReAct and Tree of Thought

As AI models are increasingly used for complex reasoning tasks — problem-solving, research, planning, and multi-step decision making — basic prompting techniques sometimes fall short. Two advanced frameworks — ReAct and Tree of Thought — were developed to push AI reasoning further. Understanding these frameworks opens the door to building more powerful and reliable AI-driven workflows.

Part 1 — ReAct Prompting

What is ReAct?

ReAct stands for Reason + Act. It is an advanced prompting framework that combines two capabilities:

  1. Reasoning: The AI thinks through a problem step by step
  2. Acting: The AI takes actions — such as searching for information, running a calculation, or using an external tool — based on that reasoning

In a standard Chain-of-Thought prompt, the AI thinks but does not act. ReAct goes further — it allows the AI to interact with external tools or data sources as part of its reasoning process, then incorporates the results of those actions back into its thinking.

ReAct Loop — How It Works

A ReAct loop follows this cycle:

  1. Thought: The AI reasons about what it needs to do or find next
  2. Action: The AI performs an action — searches, looks up a value, runs a tool
  3. Observation: The result of the action is returned to the AI
  4. Repeat: The AI uses the observation to inform the next Thought, then the next Action
  5. Final Answer: Once enough information has been gathered, the AI produces a final response

ReAct Prompt Example — Research Task

Prompt (ReAct-style):

"Answer the following question using a reasoning and action loop. For each step, write your Thought, the Action you would take, and the Observation you receive. Then use the Observation to inform the next step. Question: What is the population of the three largest cities in Brazil, and what is their combined total?"

AI Response (following ReAct structure):

Thought 1: I need to identify the three largest cities in Brazil by population.
Action 1: Search for "three largest cities in Brazil by population"
Observation 1: São Paulo, Rio de Janeiro, and Brasília are the three largest cities.

Thought 2: Now I need the population of each city.
Action 2: Look up the population of São Paulo, Rio de Janeiro, and Brasília.
Observation 2: São Paulo — approximately 12.3 million. Rio de Janeiro — approximately 6.7 million. Brasília — approximately 3.1 million.

Thought 3: I now have all three figures. I will calculate the combined total.
Action 3: Calculate 12.3 + 6.7 + 3.1
Observation 3: Total = 22.1 million

Final Answer: The three largest cities in Brazil are São Paulo (12.3M), Rio de Janeiro (6.7M), and Brasília (3.1M). Their combined population is approximately 22.1 million.

Where ReAct is Used in Practice

ReAct is most commonly used in AI agent systems — applications where AI can take actions beyond just generating text:

  • AI research assistants that search the web and synthesize findings
  • AI coding assistants that write code, test it, observe errors, and fix them
  • AI customer service bots that query databases, look up orders, and respond based on real data
  • Automated workflow agents that chain multiple tasks with real-world data inputs

Frameworks like LangChain, AutoGPT, and OpenAI's Assistants API use ReAct-style loops to power their agent behavior.

ReAct in Prompt Engineering (Without Tools)

Even without access to external tools, the ReAct thinking pattern can be used in a standard prompt to encourage structured reasoning for complex, multi-step problems:

Prompt: "Use a Thought-Action-Observation loop to reason through the following problem. Even if you cannot perform real actions, describe what you would look up and what you would expect to find. Then use those expected observations to reach a conclusion. Problem: A small business is losing money despite high sales. What are the most likely causes and how would you investigate each one?"

Part 2 — Tree of Thought Prompting

What is Tree of Thought?

Tree of Thought (ToT) is an advanced reasoning framework where the AI explores multiple possible reasoning paths before selecting the best one. Instead of following a single chain of thought in one direction, the AI branches out — considering different approaches, evaluating each, and choosing the path that leads to the best solution.

The name comes from the mental image of a tree: one problem at the root, multiple branches of reasoning, and a best answer at the end of the strongest branch.

Tree of Thought vs Chain of Thought

FeatureChain of ThoughtTree of Thought
Reasoning directionLinear — one path from start to answerBranching — multiple paths explored
Best forProblems with a clear correct pathProblems with multiple possible approaches
Error handlingIf the first path is wrong, the answer is wrongWrong paths are identified and abandoned
ComplexityModerateHigh — better for open-ended or creative problems

Tree of Thought Prompt Example — Problem Solving

Prompt:

"Use a Tree of Thought approach to solve the following problem. Generate three different strategies for approaching the problem. Evaluate the strengths and weaknesses of each strategy. Then select the best strategy and explain why. Problem: A café has seen a 30% drop in foot traffic over the past three months. What should the café owner do?"

AI Response (following ToT structure):

Strategy Branch 1 — Marketing Push
Approach: Launch social media promotions, loyalty programmes, and targeted local ads.
Strength: Increases visibility and attracts new customers quickly.
Weakness: Costs money upfront; may not address underlying quality or location issues.

Strategy Branch 2 — Product and Menu Review
Approach: Survey existing customers, update the menu based on feedback, improve quality of key items.
Strength: Targets root cause if the issue is product quality or value.
Weakness: Takes time to implement and results may be slow to appear.

Strategy Branch 3 — Operational Analysis
Approach: Review opening hours, seating layout, staff behaviour, and compare against local competitors.
Strength: Identifies structural or service problems that marketing alone cannot fix.
Weakness: Requires honest internal assessment and possible significant operational changes.

Best Strategy: Begin with Branch 3 (Operational Analysis) to understand the root cause, then combine elements of Branch 1 and Branch 2 based on findings. Fixing the root problem first ensures that any marketing spend drives visitors to an improved experience.

Tree of Thought Prompt Example — Creative Decision

Prompt:

"Use a Tree of Thought approach to brainstorm three different storyline directions for a short film about two strangers who meet during a blackout. Evaluate each direction for emotional impact, originality, and simplicity of execution. Then recommend the strongest one."

This prompt asks the AI to generate multiple creative branches, evaluate them on defined criteria, and select the strongest — much more structured than simply asking "give me a storyline idea."

When to Use Tree of Thought

  • Complex problems with no single obvious solution
  • Creative brainstorming where multiple strong ideas need to be compared
  • Strategic planning with several viable paths
  • Risk analysis where different scenarios need to be weighed
  • Design or product decisions involving trade-offs

Combining ReAct and Tree of Thought

For the most complex reasoning tasks, both frameworks can be combined. The Tree of Thought generates and evaluates multiple approaches. The ReAct loop then executes the chosen approach step by step, taking actions and incorporating observations at each step.

This combination is the foundation of advanced AI agent architectures used in professional AI engineering.

Summary of Advanced Techniques

TechniqueCore IdeaBest For
Chain of ThoughtLinear step-by-step reasoningMath, logic, multi-step reasoning
ReActReasoning + real-world actions in a loopResearch agents, tool-using AI, dynamic tasks
Tree of ThoughtMultiple reasoning branches evaluated and comparedStrategic decisions, creative choices, complex problems

Key Takeaway

ReAct combines reasoning with action — the AI thinks, acts, observes, and thinks again in a loop. This powers modern AI agent systems that interact with external data and tools. Tree of Thought extends Chain-of-Thought by exploring multiple reasoning branches, evaluating each, and selecting the best path — making it ideal for complex decisions and creative problems. Both techniques represent the frontier of prompt engineering and are increasingly important for anyone building sophisticated AI-powered workflows.

In the next topic, we will explore Negative Prompting.

Leave a Comment

Your email address will not be published. Required fields are marked *