Why This Is Asked
ReAct is the foundational pattern for building LLM agents. Interviewers ask this to see if you understand how agentic behavior is implemented — not just "the model can use tools," but the specific loop structure, why it works, and when it breaks down.
Key Concepts to Cover
- What ReAct is — interleaving Reasoning traces with Action calls
- The Thought-Action-Observation loop — the core execution structure
- Why reasoning before acting helps — reduces random tool use, improves planning
- When to use ReAct — multi-step tasks requiring dynamic planning
- Limitations — error propagation, context length, hallucinated tool calls
- Alternatives — plan-and-execute, reflexion, tree-of-thought
How to Approach This
1. What Is ReAct?
ReAct (Reasoning + Acting) is a prompting pattern where the LLM interleaves:
- Thought: Natural language reasoning about what to do next
- Action: A tool call or external action
- Observation: The result of that action
The model repeats this cycle until it reaches a final answer.
2. The Loop Structure
Thought: I need to find the current weather in London. I'll use the weather API.
Action: get_weather(location="London")
Observation: {"temp": 15, "conditions": "cloudy", "humidity": 72}
Thought: London is 15C and cloudy. Now I need to convert to Fahrenheit for the user.
Action: calculate("15 * 9/5 + 32")
Observation: 59
Thought: I have all the information. The answer is 59F and cloudy.
Final Answer: It's currently 59F (15C) and cloudy in London.
3. Why It Works
Without reasoning traces, the model chooses actions based on the original question alone. With ReAct, it:
- Explicitly plans before acting
- Can adjust its plan based on what it observes
- Reasons about whether it has enough information or needs another action
- Naturally handles multi-step problems where later steps depend on earlier results
The reasoning trace also makes the agent's behavior interpretable — you can see why it took each action.
4. When to Use ReAct
ReAct is appropriate when:
- The task requires multiple steps that can't be planned in advance
- Each step's result influences what to do next
- The agent needs to interact with external systems or APIs
- You want the agent's reasoning to be transparent and auditable
Examples: research tasks, data gathering, troubleshooting, booking flows.
5. Limitations
Error propagation: If an early step produces wrong information, all subsequent reasoning is built on a false foundation. The model rarely backtracks.
Context length: Long ReAct traces fill the context window. Multi-step tasks with many tool calls eventually exceed limits.
Hallucinated observations: The model can occasionally invent tool call results rather than actually calling the tool. The mitigation is architectural: the orchestration framework should parse the model's tool call specification in structured format, execute the real tool, and inject the actual result as the Observation. When implemented this way, the model never writes the Observation — the framework does — which eliminates this failure mode entirely.
No lookahead: ReAct is greedy — it picks the best next action without planning ahead. It can get stuck in local optima.
6. Alternatives
Plan-and-execute: First generate a full plan, then execute each step. More structured but less adaptive to unexpected results.
Reflexion: After each task attempt, the agent generates a verbal reflection on what went wrong and stores it in a persistent memory buffer. On the next attempt, it reads this accumulated reflection history to guide its approach. Unlike simple retry, Reflexion accumulates lessons across multiple episodes — making it genuinely learn from failures rather than just try again.
Tree of Thought: Explores multiple reasoning paths simultaneously, then selects the best. More accurate but much more expensive.
Common Follow-ups
-
"How does ReAct differ from a standard function-calling setup?" Standard function calling handles the Action-Observation part. ReAct adds the explicit Thought trace — asking the model to reason about what it has seen before deciding on the next action. You can implement ReAct on top of any function-calling API.
-
"How do you prevent an infinite ReAct loop?" Set a maximum number of steps (e.g., 15-20 actions). After this limit, force the model to either give a partial answer or declare that it cannot complete the task. Also add loop detection: if the model takes the same action twice with the same inputs, it's stuck.
-
"How do you implement ReAct in practice?" Most LLM frameworks (LangChain, LlamaIndex, Anthropic tool use) implement ReAct-style agents natively. In a custom implementation: prompt the model to output in Thought/Action format, parse the action, call the real tool, inject the result as an Observation, and loop until the model outputs a Final Answer.