The ReAct loop

3 trajectories·turn limit 3All algorithms

AlgoLab runs no language model. Every Thought, Action and Observation below is text a person wrote in advance and typed into this page — shown in full in the Transcript tab. Nothing here thought, decided, reasoned, or chose anything: the current node and the log replay a fixed, pre-written script, the way a transcript of a call shows what was said without the page having spoken it. A fixed turn limit, not a judgement, stops an unfinished run.

thought to action: ActActaction to observation: ExecuteExecuteobservation to thought: ContinueContinueaction to success: FinishFinishaction to recovered: FinishFinishobservation to turn-limit: Turn limitTurn limitThoughtThoughtActionActionObservationObservationSuccessSuccessRecoveredRecoveredTurn limitTurn limitStep 1 of 9: ThoughtTStep 2: not yet reachedStep 3: not yet reachedStep 4: not yet reachedStep 5: not yet reachedStep 6: not yet reachedStep 7: not yet reachedStep 8: not yet reachedStep 9: not yet reached
  • Current entry

Entry 1 of 9 is a Thought: I need to find the capital of Australia before I can answer the question.

Entry 1 of 9 is a Thought: I need to find the capital of Australia before I can answer the question.
  1. 1The transcript’s next entry is a Thought, shown in full below.
  2. 2The transcript’s next entry is an Action, shown in full below.
  3. 3The transcript’s next entry is an Observation, shown in full below.
  4. 4The transcript ends here: a fixed rule — a finish action, or the turn limit — stops the run.
Transcript entries shown
1
Thought-action-observation cycles completed
0

The ReAct loop

AlgoLab runs no language model. Every Thought, Action and Observation below is text a person wrote in advance and typed into this page — shown in full in the Transcript tab. Nothing here thought, decided, reasoned, or chose anything: the current node and the log replay a fixed, pre-written script, the way a transcript of a call shows what was said without the page having spoken it. A fixed turn limit, not a judgement, stops an unfinished run.

Three fixed transcripts, each a short sequence of Thought, Action and Observation entries written in advance, replayed one entry at a time through one small state machine. The state machine has three ordinary states (Thought, Action, Observation) and three terminal states (Success, Recovered, Turn limit). An Action entry that is a finish action ends the run immediately at Success or Recovered; otherwise an Observation entry follows, and the run either returns to Thought or, once a fixed turn limit of cycles is reached, ends at Turn limit instead.

Why it matters, and what it costs

The Thought, Action, Observation loop — often called ReAct, after the paper that named it — is the shape behind most tool-using language-model agents: one entry labelled as a thought, one entry naming an action to take, and one entry reporting what the action returned, repeated until a final answer is produced or an external limit is hit. This tool shows the shape of that loop and the three distinct ways it can end, using transcripts written by hand rather than a live run of any agent.

How it works

Worth noticing

Where the transcripts come from

Three transcripts, each a short sequence of Thought, Action and Observation entries, held attools/react-loop/src/data/trajectories.v1.json and shown in full in the tool’s Transcript tab. Every entry was typed by a person in advance, the same way a textbook writes out a worked example of a transcript format. One (“a successful run”) reaches a final answer after two productive search actions. A second (“cut off by the turn limit”) keeps searching without success and is stopped by a fixed turn limit of three cycles — a fixed, pre-set count, not a response to how the run was going. A third (“a tool failure and a different next action”) records one action’s result as an error and shows a different, pre-written action in response, reaching a final answer two steps later.

The state machine, and what it actually proves

Six fixed states — Thought, Action, Observation, and three terminal states, Success, Recovered and Turn limit — and six fixed transitions between them, defined once intools/react-loop/src/state.ts and replayed, never recomputed, for every trajectory. There is no theorem behind this tool the way there is behind the other six entries in this catalogue: a fixed transcript carries no mathematical property to prove. Whattools/react-loop/test/react-loop.test.ts does check, directly: every frame’s current state matches the trajectory’s own position, a transition is only ever taken along a real edge of the six listed above, the append-only log never loses, reorders or rewrites an entry once revealed, and the three shipped trajectories reach three distinct terminal states — Success, Recovered and Turn limit, respectively, and no trajectory reaches the wrong one.

What this does not show

Three short, hand-written transcripts over one small, fixed state machine. It does not show a real tool-using agent choosing what to search for, parsing a real tool’s output, or adjusting its plan based on what comes back — none of that happens here, because nothing in this tool thought, decided, reasoned, or chose anything. A real system’s loop length, tool set and stopping conditions all vary by task and by design; here all three are fixed in advance and shown in full.

Source

Yao, Zhao, Yu, Du, Shafran, Narasimhan & Cao, “ReAct: Synergizing Reasoning and Acting in Language Models” (ICLR 2023, arXiv:2210.03629) defines the Thought, Action, Observation loop this tool’s fixed state machine replays, terminating on a Finish action or an external step limit. This tool runs no part of that paper’s method or any language model: it replays three transcripts written by hand through the loop’s own shape.

Worth comparing

All algorithms