A ReAct agent implements the "Reasoning and Acting" (ReAct) framework, combining chain-of-thought (CoT) reasoning with external tool use to enhance an LLM's ability to handle complex tasks in agentic workflows. Introduced by Yao et al. in their 2023 paper "ReACT: Synergizing Reasoning and Acting in Language Models," this paradigm integrates reasoning and action-taking, enabling AI agents to autonomously plan, execute, and adapt to unforeseen circumstances. Unlike traditional AI, ReAct agents do not separate decision-making from task execution, marking a step beyond conversational chatbots toward autonomous problem-solving.
Structure: alternating Thoughts (CoT reasoning), Actions (tool use), and Observations (assessment of results) in a feedback loop.
Introduced by Yao et al. (2023); popularized in frameworks like LangChain, LlamaIndex, and BeeAI.
Relies on the LLM's reasoning ability; larger models benefit ReAct agents, but multiagent setups can delegate subtasks to smaller models.
Differences from function calling: ReAct offers greater adaptability for complex/dynamic tasks, while function calling is more efficient for predictable tasks.
Implementation via ReAct prompting: a system prompt that defines the thought-action-observation format and available tools, often with a scratchpad for reasoning.
Advantages: versatility, adaptability (dynamic tool selection, learning from mistakes), explainability (verbalized reasoning), and accuracy (reduced hallucination via grounding to external sources).
End conditions: maximum iterations, confidence threshold, or stopping after final answer.
Concepts
Chain-of-Thought (CoT) Reasoning: Step-by-step verbal reasoning that decomposes tasks into manageable subtasks.
Tool Use: Actions that invoke external tools, APIs, or databases to gather information or perform operations.
Observation: The result returned after executing an action, used to reevaluate and decide next steps.
ReAct Prompting: The prompt engineering technique that instructs the LLM to follow the thought-action-observation loop, often including available tools and format specifications.
Function Calling: An alternative paradigm where LLMs are fine-tuned to output structured JSON for tool calls; simpler but less flexible than ReAct.
LangGraph's ZERO_SHOT_REACT_DESCRIPTION: An example system prompt that defines tools and format for a ReAct agent without requiring additional examples.
Details
The ReAct framework draws inspiration from human intuitive planning, where an inner monologue guides step-by-step decision-making. An everyday analogy is packing for a trip: you consider conditions (thought), check weather forecast (action), receive information (observation), then decide to check your closet (next action), adjusting when you encounter an obstacle.
The formal pattern consists of three components:
Thoughts: Chain-of-thought reasoning that breaks down the larger task.
Observations: Feedback from actions that informs the next thought or produces a final answer.
The agent iterates the loop until an end condition is met, such as a maximum number of iterations or a confidence threshold for the answer. This feedback loop allows the agent to adapt based on new information.
ReAct Prompting
To implement a ReAct agent, the system prompt (or user context) instructs the LLM to follow the ReAct paradigm and specifies available tools. An example from LangChain's LangGraph is the ZERO_SHOT_REACT_DESCRIPTION prompt, which defines tools like Wikipedia, DuckDuckGo search, and a calculator. It specifies a format:
Question
Thought
Action
Action Input
Observation
... (repeat as needed)
Final Answer
The zero-shot nature means no further examples are required for the LLM to behave as a ReAct agent. Effective ReAct prompting should:
Guide chain-of-thought reasoning interleaved with actions.
Define actions as external tools or API calls.
Instruct the model to make observations and reassess context.
Optionally specify repeat (loop) and end conditions.
Output a final answer after meeting end conditions, often using a scratchpad for reasoning.
Comparison with Function Calling
The choice between ReAct and function calling depends on the use case:
Function calling (popularized by OpenAI in June 2023 and supported by models like IBM Granite, Meta Llama, Anthropic Claude, Google Gemini) is fine-tuned to output structured JSON for tool calls. It is faster, token-efficient, and simpler for straightforward or predictable tasks.
ReAct is better for complex, dynamic, or unpredictable tasks where step-by-step reasoning is beneficial. It offers greater adaptability and customizability in how and when the model chooses a tool, at the cost of additional tokens for reasoning.
Implementation and Frameworks
ReAct agents can be built from scratch in Python or using open-source frameworks such as BeeAI, LlamaIndex, and LangChain's LangGraph, which offer preconfigured ReAct agent modules. The paradigm's popularity has produced extensive literature and tutorials.
Performance Considerations
The central LLM's ability to "verbally" reason is critical. To minimize cost and latency, a multiagent architecture may use a larger, more capable model as the central agent that delegates subtasks to smaller, efficient models.
The ReAct framework advanced LLM-driven agentic workflows, from grounding via RAG to subsequent developments like Reflexion. Its inherent qualities—versatility, adaptability, explainability, and accuracy—make it a foundational paradigm for building autonomous AI agents.