ReAct and the agent loop
Thoughts in the action space, stopping, recovery, and the loop’s quadratic cost.
Act only or reason only
Tool use gave actuators; chain of thought gave serial compute — separately. Act only fetches facts but has nowhere to write what was learned or why a search failed. Reason only plans fluently and fabricates freely. Yao et al. (2023) compared both with ReAct on HotpotQA and FEVER (PaLM-540B). ReAct beat act-only; against reason-only results were mixed; the best scores combined ReAct with self-consistency because the failure modes are complementary (CoT: hallucinated facts; ReAct: reasoning errors and dead-end searches).
Thoughts as actions
Key idea. Enlarge the action space to . At each step :
A thought is a write to the agent’s memory (the context). For knowledge tasks Yao et al. used search, lookup, finish with dense thoughts in the exemplars; for long decision tasks, sparse thoughts.
A trace and error analysis
A full trace decomposes the question, extracts facts from observations, switches tools when the first sentences lack a year, recovers from a failed search using similar titles, sends arithmetic to a calculator, and stops with finish. Thoughts carry task state that act-only would have to re-infer every step.
Fine-tuning on a few thousand successful ReAct trajectories flipped the scale picture: fine-tuned PaLM-8B beat prompted PaLM-62B on HotpotQA. Modern agent models train on such trajectories by default.
Stopping and loops
Do not rely on the model alone to stop: final action, step/token/cost/time budgets, exact repetition of (action, observation), and weaker “no progress” signals. At temperature 0 an uninformative failure leaves the context almost unchanged — a fixed point. Flagging “Repeated action… try something else” in the observation changes . When the budget expires: return a marked partial answer, fall back (as ReAct did to self-consistency), or ask the user — not a silent guess.
Error recovery
Reliability compounds: . If errors occur with rate and are noticed and repaired with probability ,
With , , : , expected extra steps . Informative observations and thoughts that read them do most of the work. Silent wrong facts are never repaired.
Plan first or interleave
ReAct decides one step at a time. Plan-and-execute (ReWOO, plan-and-solve) writes the tool plan first; workers run without the model until composition. On HotpotQA, ReWOO reported similar accuracy with ~5× fewer tokens — at the price of adaptivity unless replanning is added. Hybrids keep a short plan at the end of context and revise it when observations contradict it (Planning with language models).
Loop cost and next
Every step re-reads the whole context. With prefix and tokens per step,
For , , : 33 500 input tokens; at : 314 000. Prompt caching bills the repeated prefix cheaply but does not shrink generation or tool latency. Long tasks need summarisation and external memory.
Next: treat the context as a managed budget — context and memory.
Check your understanding
The same questions as in Pulse. Answers are shared between modes.
Answers are saved on the server and tied to this browser until you sign in.