Mastering AI Agent Development
Agentic Reasoning with ReAct
Beyond Prompt and Response
Interacting with a basic large language model is often a linear conversation. You ask a question, and it provides a response. But to solve complex problems, an AI needs to do more than just answer. It needs to work. This involves breaking a goal down into smaller pieces, gathering information, and using external tools to find answers it doesn't already know.
This is where agentic reasoning comes in. Instead of a simple back-and-forth, the AI enters an iterative loop of thinking and doing. This allows it to tackle tasks that require multiple steps or up-to-date information from the outside world.
The ReAct (Reasoning + Acting) model represents the cutting edge in AI agent design, combining analytical thinking with immediate action in a continuous feedback cycle.
This pattern, short for Reasoning and Acting, equips an LLM with a simple but powerful workflow to solve problems autonomously.
The ReAct Loop
The ReAct framework operates in a continuous cycle with three distinct phases: Thought, Action, and Observation. The agent repeats this loop until it has gathered enough information to accomplish its original goal.
- Thought: The LLM considers the goal and its current knowledge. It formulates an internal monologue, or a reasoning trace, to decide what it needs to do next. This is its plan of attack.
- Action: Based on its thought process, the agent chooses an action. This usually involves calling a specific tool, like a web search, a calculator, or a database query.
- Observation: The agent receives the output from the tool it just used. This new piece of information is the observation.
The observation feeds directly into the next Thought phase, starting the cycle over. The agent now has new information to inform its next step.
Let's trace this loop with a query that requires multiple steps: "Who is the CEO of the company that acquired Figma, and what is their current stock price?"
An LLM's internal knowledge might be outdated or incomplete. It likely doesn't know the current stock price and might not have the most recent acquisition details. It needs tools to find this information.
# Initial Goal: Find CEO of Figma's acquirer and their stock price.
Thought 1: I need to identify the company that acquired Figma.
Action 1: search("who acquired Figma")
Observation 1: Adobe acquired Figma.
Thought 2: The company is Adobe. Now I need to find the CEO of Adobe.
Action 2: search("CEO of Adobe")
Observation 2: Shantanu Narayen is the CEO of Adobe.
Thought 3: I have the CEO's name. Next, I need Adobe's stock price. I should first find their stock ticker symbol.
Action 3: search("Adobe stock ticker")
Observation 3: The stock ticker for Adobe is ADBE.
Thought 4: The ticker is ADBE. Now I can use the stock price tool.
Action 4: getStockPrice("ADBE")
Observation 4: 450.76
Thought 5: I have all the necessary information. The CEO is Shantanu Narayen, and the current stock price is $450.76. I can now provide the final answer.
Final Answer: Shantanu Narayen is the CEO of Adobe, the company that acquired Figma. Their current stock price is $450.76.
Orchestrating the Flow
The agent's ability to generate a reasoning trace is key. The prompt that kicks off the process doesn't just ask for an answer; it asks the model to think step-by-step and decide when to use a tool. The system then parses the model's output, looking for an Action command.
When it detects an action, the system pauses the LLM's execution, runs the specified tool (like making a real web search), and then feeds the result back into the LLM as the Observation. This stop-and-resume flow is fundamental. The LLM isn't running a continuous program; it's a reasoning engine that is called repeatedly, each time with more context.
The process stops when the LLM concludes in its Thought step that it has enough information to give a final answer, as seen in the last step of the example above. This makes the process non-deterministic—the agent itself decides how many loops it needs to complete its task.
Transitioning from simple prompts to this agentic loop is a significant shift. It allows an AI to move from being a repository of static knowledge to a dynamic problem-solver that can interact with live systems and data to achieve complex goals.
What does "ReAct" stand for in the context of AI agents?
What is the correct order of phases in a single ReAct loop?
This iterative approach forms the basis for more complex AI agents.