mediumAI Engineering

What is the ReAct pattern and why did it become the default for agents?

66 views
01

Understand the problem

Interleaving reasoning and acting: thought, action, observation on repeat.

react-patternagentsreasoning
02

Attempt it yourself

Sketch your approach before reading the solution — that's what interviews test.

Stuck? AI Nudge Available

Get a conceptual hint to guide your logic without spoiling the final implementation.

03

Study the solution

The solution is waiting

Give it an honest attempt first — then compare your thinking with the full walkthrough.

04

Read the code

A ReAct trajectory (what you read when debugging)
Thought: The user asks for Q2 refunds for customer 811. I need order data first.
Action:  search_orders({ customer_id: "811", from_date: "2026-04-01",
                         to_date: "2026-06-30", status: "returned" })
Observation: 3 returned orders: #90312 ($120), #90417 ($60), #90583 ($75)

Thought: Refund totals come from the payments tool, not order totals.
Action:  get_refunds({ order_ids: ["90312", "90417", "90583"] })
Observation: refunds: 90312=$120, 90417=$60, 90583=$0 (pending)

Thought: Two completed refunds ($180), one pending. I can answer precisely.
Final:   "Q2 2026: $180 refunded across 2 orders; 1 refund ($75) still pending."
05

Join the discussion

Discussion (0)

Sign in to join the discussion.

No responses yet. Be the first to share what you think.