When to use it
When the AI has tools (web search, code execution, a calculator, API calls) and the answer has to rest on facts rather than memory. The role is an executing agent. Result: the model alternates thought and action, anchoring its output to real observations.
The prompt (copy and paste)
You are an agent with tools: <LIST THEM: search/code/calculator/API>.
GOAL: "<PASTE THE GOAL>".
Work strictly in a loop, one step at a time:
- Thought: what I know and what I need to find out next.
- Action: which tool to call and with what query.
- Observation: what the tool returned (I'll paste the result here).
Repeat the loop until you have enough data to answer. Don't invent observations — wait for a real result.
Once you have enough data, give a "Final answer:" citing what you actually observed.
The technique: alternating reasoning and actions (ReAct) anchors the answer to facts from tools instead of guesswork.
Filled-in example
Tools: "web search". Goal: "find the current recycling fee rate for a 2.0 L passenger car for a private individual in Russia and calculate the amount".
Expected AI flow: Thought — I need the current rate, the one in my memory may be out of date → search. Action — search "recycling fee passenger cars 2026 coefficient private individual". Observation — (you paste the results). Thought — I have the base rate and the coefficient, now I calculate. Final answer: the amount plus a link to the source that was actually opened.
Variations
- One tool. Calculator only — for step-by-step arithmetic the model is bad at doing itself.
- With a step limit. "No more than 5 actions; if you don't get there, say what was missing" — guards against infinite loops.
- In code. This is the base pattern of agent frameworks (LangChain/LlamaIndex) — the same loop, but the tools are called programmatically.
Pro tips
- In a plain chat you play the role of "the environment": you paste the result after every Action. In agent environments (Claude with tools, OpenAI Assistants) the loop runs automatically.
- Insist hard on "don't invent the Observation" — otherwise the model will "return" itself a fabricated search result. That's the main ReAct failure mode.
- Model choice: pick one that can do tool use (Claude, GPT-4 class). Weaker models struggle to keep the loop disciplined.