License YOLO
Back to Ultralytics Glossary

ReAct Prompting

ReAct prompting has an LLM alternate reasoning steps with actions such as searches or tool calls, reading each result before deciding what to do next.

ReAct prompting, short for reasoning and acting, has a large language model (LLM) alternate between writing a thought about the task, taking an action such as a search or a tool call, and reading the observation that the action returns, repeating the cycle until it can answer. The reasoning plans and tracks the actions, and the actions bring in facts from outside the model, so answers rest on retrieved evidence instead of memory alone. Shunyu Yao and colleagues at Princeton University and Google Research introduced the method in ReAct: Synergizing Reasoning and Acting in Language Models, presented at ICLR 2023. With only one or two examples in the prompt, ReAct beat imitation learning and reinforcement learning methods trained on far more data by 34 and 10 percentage points of absolute success rate on the ALFWorld household tasks and the WebShop online shopping benchmark. Today's tool-using AI agents run the same loop.

How ReAct Works#

A ReAct prompt is a few-shot prompt with a handful of example trajectories, each a question followed by interleaved Thought, Action, and Observation lines. Given a new question, the model writes a thought and an action, then stops. Controller code parses the action, runs the matching tool, appends the result as the next observation, and calls the model again with the longer transcript. For question answering, the paper gave the model a minimal Wikipedia interface with three actions: search[entity] returns the first sentences of a page, lookup[string] returns the next sentence on the current page containing a string, and finish[answer] ends the task.

A ReAct Trajectory#

This example from the paper's prompt for HotpotQA, a question answering dataset that requires combining facts from several Wikipedia pages, shows the loop recovering from a first search that does not contain the answer:

Question: What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into?
Thought 1: I need to search Colorado orogeny, find the area that the eastern sector of the Colorado orogeny extends into, then find the elevation range of the area.
Action 1: Search[Colorado orogeny]
Observation 1: The Colorado orogeny was an episode of mountain building (an orogeny) in Colorado and surrounding areas.
Thought 2: It does not mention the eastern sector. So I need to look up eastern sector.
Action 2: Lookup[eastern sector]
Observation 2: (Result 1 / 1) The eastern sector extends into the High Plains and is called the Central Plains orogeny.
Thought 3: The eastern sector of Colorado orogeny extends into the High Plains. So I need to search High Plains and find its elevation range.
Action 3: Search[High Plains]
Observation 3: High Plains refers to one of two distinct land regions:
Thought 4: I need to instead search High Plains (United States).
Action 4: Search[High Plains (United States)]
Observation 4: The High Plains are a subregion of the Great Plains. From east to west, the High Plains rise in elevation from around 1,800 to 7,000 ft (550 to 2,130 m).
Thought 5: High Plains rise in elevation from around 1,800 to 7,000 ft, so the answer is 1,800 to 7,000 ft.
Action 5: Finish[1,800 to 7,000 ft]

Thought 2 notices that the page lacks the needed fact and switches to a lookup, and Thought 4 resolves an ambiguous search, two corrections that a fixed sequence of searches could not make.

Results and Limits#

Grounding reasoning in observations mainly reduces invented facts. In the paper's error analysis on HotpotQA with PaLM-540B, hallucination caused 56% of chain-of-thought failures and none of ReAct's, and chain-of-thought's false positive rate was 14% against 6% for ReAct. The loop has its own failure mode: searches that return nothing useful made up 23% of ReAct's errors, because an empty observation derails the reasoning that follows. On HotpotQA, ReAct alone reached 27.4% exact match against 29.4% for chain-of-thought, while on the Fever fact-checking task it led with 60.9% accuracy against 56.3%. The best HotpotQA result, 35.1%, came from combining the two: falling back from ReAct to self-consistent chain-of-thought when ReAct failed to answer within a set number of steps.

ReAct in Modern Agents#

Current LLM APIs build the action step into the model through function calling: the model emits a structured tool call instead of a line of text, the application runs it and returns the result, and the loop is the same Thought-Action-Observation cycle. Tools reach far beyond search, including code execution, databases, browsers in computer-use agents, and services exposed through the Model Context Protocol (MCP). In agentic RAG, the agent decides when and what to retrieve, instead of retrieving once before generating. Because an agent acts on text it reads, ReAct systems inherit the risk of prompt injection through tool results, which is why tool permissions are kept narrow and risky actions often run in sandboxes.

Ask AI in Ultralytics Platform AutoTrain acts through tools in this way: it runs ul cloud commands from the Platform CLI to find datasets, start training runs, compare completed models, export them, or deploy one, and builds its reply on what those commands return.

  • Chain-of-thought prompting: Reasons in a single pass from the model's own knowledge, with no way to check a fact mid-answer. ReAct adds actions that fetch new information between reasoning steps.
  • Prompt chaining: The developer fixes the sequence of model calls in code. In ReAct, the model chooses each next action from what it has observed so far.
  • Tree of Thoughts (ToT): Searches over several candidate reasoning paths, backtracking from weak ones, without touching an outside environment. ReAct follows one path but grounds it in observations.
  • Reasoning models: Trained to write long reasoning before answering, and in many current systems they also call tools between reasoning steps, which builds the ReAct loop into the model itself.

Explore solutions

Computer vision in sports

Computer vision in sports

Discover how Ultralytics YOLO powers sports vision with player and ball tracking, performance analytics, coaching insights, and athlete rehabilitation.
Learn more
Computer vision for aerial imagery

Computer vision for aerial imagery

Turn drone and aerial imagery into real-time insights for agriculture, aquaculture, conservation, and geospatial analysis with Ultralytics YOLO.
Learn more
Computer vision in aerospace

Computer vision in aerospace

Apply computer vision in aerospace with Ultralytics YOLO for aircraft inspection, runway FOD detection, airport ground operations, and composite defect detection.
Learn more
Computer vision in security

Computer vision in security

Protect every site with Ultralytics YOLO models. Vision AI powers perimeter monitoring, threat detection, license-plate recognition, and workplace safety.
Learn more
Computer vision in robotics

Computer vision in robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Computer vision in logistics

Computer vision in logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Computer vision in retail

Computer vision in retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Computer vision in healthcare

Computer vision in healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Computer vision in manufacturing

Computer vision in manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Computer vision in automotive

Computer vision in automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Computer vision in agriculture

Computer vision in agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more

Let's build the future of AI together!

Begin your journey with the future of machine learning