Large language models (LLMs) are incredibly powerful at processing and generating text. However, they have fundamental limitations: their knowledge is frozen at the time they were trained, and they can't take actions in the real world. An AI agent is a system designed to overcome these limits by giving an LLM access to external tools.

You've seen this in action when a chatbot can browse the web for current information or use a calculator for precise math. This capability is often powered by a simple but powerful framework known as ReAct, which stands for Reason + Act. This guide will break down how this framework works, turning a static LLM into a dynamic problem-solver.
The Core Idea: Reason, Then Act
The ReAct framework creates a loop that mimics how humans solve problems. When faced with a complex question, you don't just know the answer. You first think about a plan (Reason), then you take a step to execute that plan, like performing a web search (Act). You look at the result, think again (Reason), and take the next step (Act). You repeat this until you have the final answer.
An AI agent using the ReAct framework does the same thing:
- Reason: The LLM analyzes the user's goal and its current information. It thinks step-by-step about what it needs to do next and which tool would be most helpful.
- Act: The agent executes the action decided by the LLM, such as calling a search engine API with a specific query.
- Observe: The agent takes the output from the tool (e.g., the search results) and feeds it back into the LLM's context.
This loop repeats, with the LLM refining its reasoning at each step based on the new information it gathers, until it determines it has enough information to answer the user's original query.
A Walkthrough: How an Agent Answers a Question
Let's say a user asks: "What is the current price of the top-selling science fiction book?"
An LLM alone can't answer this because it needs two pieces of real-time information. Here's how a ReAct agent would tackle it:
- Step 1 (Reason): The LLM thinks, 'I need to find the top-selling sci-fi book first. Then I need to find its current price. My first step is to use the search tool to find the current bestseller list.'
- Step 2 (Act): The agent calls the search tool with the query 'top selling science fiction books'.
- Step 3 (Observe): The search tool returns a list of articles. The agent adds this text to the LLM's context.
- Step 4 (Reason): The LLM analyzes the search results and thinks, 'The results indicate that "Dune" is currently at the top of several lists. Now I need to find its price. I will use the search tool again to find the price of the book "Dune" on a major retail site.'
- Step 5 (Act): The agent calls the search tool with the query 'price of Dune book on Amazon'.
- Step 6 (Observe): The search tool returns a price, like '$15.99'. The agent adds this to the context.
- Step 7 (Reason): The LLM thinks, 'I have found the top book ("Dune") and its price ($15.99). I now have all the information needed to answer the user's question.'
- Step 8 (Final Answer): The agent generates the final response for the user: 'The current top-selling science fiction book is "Dune", and its price is approximately $15.99.'
What Can Be a 'Tool'?
In the context of AI agents, a 'tool' can be almost any function or external data source the LLM can be given access to. Common examples include:
- Web Search: To get up-to-date information.
- Calculator: To perform precise mathematical calculations.
- Code Interpreter: To run Python code for data analysis or complex logic.
- Database Query: To retrieve specific information from a company's internal database.
- API Calls: To interact with other software, like checking the weather or booking a flight.
The ability to choose and use the right tool for the job is what makes agents so much more capable than standalone LLMs.
FAQ about the ReAct Framework
Is this actual artificial general intelligence (AGI)?
No. While agents are a step towards more autonomous systems, they are still operating within a very constrained loop defined by the developer. They are not conscious or truly thinking; they are simply using the LLM's pattern-matching ability to generate text that represents a reasoning process.
How does the LLM know which tool to use?
The developer provides the LLM with a list of available tools and a clear description of what each tool does. The LLM then uses this information to decide which tool is most appropriate for the task at hand. This is often done through a technique called function calling.
What's the difference between ReAct and prompt chaining?
Prompt chaining is a linear process where the output of one prompt becomes the input for the next. ReAct is a dynamic loop where the LLM can choose from multiple tools at each step and can decide on its own when the task is complete.
Key Takeaways
- AI agents overcome the limitations of LLMs by giving them access to external tools.
- The ReAct (Reason + Act) framework allows an agent to reason about a problem, act by using a tool, and observe the results in a loop.
- This process mimics human problem-solving and allows agents to tackle complex, multi-step tasks.
- A 'tool' can be anything from a web search engine to a calculator or a connection to a private database.
- Agents are not sentient; they use an LLM's text-generation capabilities to create a plan and execute it.
Related Reading
- What Is Function Calling? How LLMs Use Tools to Get Live Data
- What Is a Vector Database? A Simple Guide for AI Builders
- Prompt Chaining Workflow: How to Tackle Complex Tasks with AI