Skip to content
AI & Machine Learning

ReAct (Reasoning and Acting)

Definition

ReAct is a pattern for AI agents in which the model alternates between writing down its reasoning and taking an action, such as a search or a tool call, then reasons about what came back before the next step. It is the loop behind many agents that use tools.

The loop

  1. ThoughtThe model notes what it knows and what it needs next.
  2. ActionIt calls a tool, such as a search or a database lookup.
  3. ObservationThe tool's result is added to the conversation.
  4. Repeat or answerIt reasons about the result and acts again, or gives its final answer.

Example trace

  1. Thought
    I need the order’s status before I can say why it’s late.
  2. Action
    get_order("1042")
  3. Observation
    Status: held at customs in Lagos since Monday.
  4. Thought
    I should check how long customs holds usually take there.
  5. Action
    search_help("customs hold Nigeria")
  6. Observation
    Most holds clear within 3 to 5 working days.
  7. Answer
    Your order is held at customs in Lagos. Holds usually clear in 3 to 5 working days, so expect it by next Tuesday.
Each observation goes back into the prompt before the next thought, so the model plans from real results rather than guesses. Set a limit on the number of steps, and log the trace: it shows exactly where a wrong answer went off track.

Case study

Worked example