Agentic AI & Tool Use

reasoning–acting loop (ReAct)

A reasoning–acting loop lets a language model alternate between thinking out loud and doing something in the world. Instead of emitting one long answer, the agent writes a short thought, takes an action such as a search or a calculation, reads the observation that comes back, and then thinks again. Picture a detective who reasons one step, checks a clue, updates the theory, and only then decides the next move — the reasoning and the doing reinforce each other turn by turn.

Formally, each turn appends a (thought, action, observation) triple to the context, and the model is decoded autoregressively on the growing trace. Actions are drawn from a fixed tool vocabulary such as search[query], lookup[entity], or finish[answer]; the environment returns an observation string that is fed back verbatim. Interleaving grounds the chain of thought in external evidence, cutting hallucination relative to pure reasoning, while the explicit reasoning steers which tool to call relative to pure acting.

ReAct is a prompting and control pattern, not a trained model: its reliability rests on the base model's instruction-following and on robust parsing of the action syntax. Long traces inflate context cost and can drift off task, so production systems cap the number of loops and add a verifier or an explicit stop condition.

Thought: I need the population, then divide by area.
Action: search["Taiwan population 2024"]
Observation: ~23.4 million
Thought: Now divide by 36,197 km^2.
Action: calc[23400000/36197]
Observation: 646
Action: finish["~646 people per km^2"]

A short ReAct trace interleaving thoughts, tool actions, and observations until a finish action.

ReAct grounds reasoning in observations; it does not by itself guarantee the agent recovers from a bad action — error recovery still needs reflection or a verifier.

Also called
ReActthought-action-observation loop推理行動迴圈