ReAct
Think, act, look at what happened, think again — the loop underneath essentially every agent, and it's four lines of pseudocode.
When not to use it
- When the sequence is known. If you know the steps, write them. A loop that rediscovers your workflow each time is slower, costlier, and occasionally wrong.
- For long-horizon tasks. Error compounds multiplicatively. Twenty steps at 95% is 36%.
- When latency matters. Each iteration is at least two round-trips.
- Without an iteration cap. It will not notice it's stuck. That's not pessimism, it's the observed behaviour.
Reach for something else instead
- A fixed pipeline — when the steps are known, which is more often than agent enthusiasm suggests.
- Single tool call — many "agent" tasks are one function call with extra ceremony.
- Plan-and-execute — plan once, then run. Cheaper, and worse at recovering from surprises.
- Human-in-the-loop — put a person at the step that actually needs judgement.
Sources & further reading
- Yao et al. (2022), ReAct: Synergizing Reasoning and Acting in Language Models — the paper; interleaving beats either half alone.
- Valmeekam et al. (2023), On the Planning Abilities of Large Language Models: A Critical Investigation — why the loop's short horizon is doing more work than the model's planning.
- Liu et al. (2023), Lost in the Middle: How Language Models Use Long Contexts — why long traces degrade even though nothing is deleted.
Primary sources, listed so you can check the claims on this page rather than take them on trust.
Where people go wrong
- Treating the Thought trace as an explanation. It's generated text alongside the action, not a record of the computation.
- Dumping raw tool output into the observation. It poisons every subsequent step.
- Expecting per-step accuracy to be end-to-end accuracy. 95% over five steps is 77%.
- Using an agent where a script would do. Most of them would.