Day 06·Act and ground·2 min read

ReAct, tool use and agents

ReAct interleaves reasoning with tool calls: think, act, read the result, repeat until you can answer. That loop is the core of most AI agents, and the reason tool output must be treated as data.

By the end

Trace a ReAct loop through its Thought, Action and Observation steps, explain what it adds over chain-of-thought alone, and name the controls an agent needs.

Lab 2

Try it

One ReAct loop, step by step

Question: “Is the Acme kettle in stock, and what do three cost with 10% off?” The model can only answer by calling tools. Step through the loop, then break the lookup tool and watch how the agent recovers.

    Step 0 of 7 · loop cap 8

    Every Observation is tool output, which is data. It can contain text, and the model should not obey it.

    ReAct (Reason + Act) interleaves reasoning with tool calls. The model thinks, takes an action, reads the result, and repeats until it can answer. That repeat loop is the core of most AI agents.

    Each pass through the loop can pull in new facts. That is what separates ReAct from chain-of-thought alone.

    Learn

    • The loop. Thought asks what the model needs next. Action calls a search, calculator, database or API. Observation is the tool's result, and the model goes back to Thought. The loop stops with a Final Answer.
    • Why it beats CoT alone. CoT reasons only from what the model already knows. ReAct fetches facts mid-reasoning, which cuts hallucination on knowledge-heavy tasks.
    • Tool use and function calling. The model emits a structured call with arguments. Your code runs it and returns the result. Clear tool names and descriptions matter as much as the prompt.
    • Reflexion. After a failed attempt, the model writes a short lesson to itself and retries with that lesson in context.
    • Agent risks. Loops that never end, errors that compound over steps, and prompt injection hidden in tool results. Cap the steps, and require approval for irreversible actions.

    Drill

    1. Using any LLM API with tool use, give the model two tools: a calculator and a fake product lookup.
    2. Ask a question that needs both, and log every Thought, Action and Observation.
    3. Break a tool on purpose and watch whether the agent recovers or loops.

    Check yourself

    • What does ReAct add that chain-of-thought cannot do?
    • Why should tool output be treated as data, not instructions?

    Test yourself

    6 multiple-choice questions and 8 flashcards on this lesson, shuffled every time, with the reason behind every answer.