Reasoning and acting in one message
A language model on its own can only answer from what it remembered in training. ReAct (Yao et al., 2023) lets it look things up while it answers: the model writes a Thought, a sentence about what it knows and what is missing, then an Action, a call to a tool written as plain text such as search[Martin Luther birth year]. The program running the loop reads the action, runs the tool and pastes its result back in as an Observation, and the model writes the next Thought. The loop ends when the model writes finish[answer], or when it runs out of turns.
This tab runs that loop with Qwen3-1.7B, thinking mode off so that the Thoughts are its only reasoning, on eight questions that each need one or two facts and often a subtraction. Its tools are search, which returns the two closest of the 2,067 SQuAD validation paragraphs the Retrieval tabs index, and calculate, which evaluates arithmetic. The reference answers are computed from numbers quoted from those paragraphs, so every question can be answered from the corpus.
Where a turn stops
The whole run is one assistant message that grows. A turn is greedy decoding until one of three things happens: the model writes the stop string Observation:, it ends its message with its end-of-turn token, or it reaches 256 tokens. The stop string matters because the model has learnt the pattern and would otherwise write the observation itself. The panel When nobody stops it lets turn 1 run 48 tokens past the stop: on question 1 the model goes on to write that Martin Luther was born in 1488, and on question 8 that Doctor Who was first broadcast on 23 April 1963. Both are wrong, and the real tool returned 1483 and 23 November.
So the loop keeps the tokens up to the stop, drops the rest (the grey Cut by the stop segments in One message, turn by turn) and appends the tool's real text, drawn in amber because the model did not write it. Of the 30 turns recorded, 13 stopped at the stop string and 17 ended with the end-of-turn token: Qwen3 often closes its message right after the action, and the loop treats that the same way.
A key-value cache keeps the earlier turns, so each turn costs only its new tokens. The page checks that this changes nothing: one forward pass over each final message without the cache picks the same 1,143 kept tokens.
Reading the action
The loop reads the last Action: tool[argument] in a turn with a regular expression. Text that does not match comes back as an observation that says the action is invalid and repeats the three forms. The cards in Thought, action, observation plot, for each turn, the probability the model gave the first token of its tool's name: how sure it was which tool to use, from the 8 most likely next tokens stored at every written token.
The search embeds the query with bge-small-en-v1.5 and returns the two paragraphs with the smallest distance to it, exactly as the HNSW tab's exact search does; the turn panel lists both hits and marks the one that holds the evidence. calculate walks Python's syntax tree and accepts numbers and arithmetic operators only, so the model's expression can never run other code.
What happened
ReAct got 2 of the 8 questions right and the same model asked the question alone got none, as the strip's grid shows. Every run ended with finish, but most finished wrongly, and the failures are the ones the ReAct paper describes:
- Format. On question 1 the model found both birth years and computed 373, then wrote
Finish[Answer: 373]without theAction:prefix. The loop rejected it, and the model then copied the placeholderfinish[answer]from the loop's own message. On question 6 it read the right paragraph, said the run lasted from 1963 to 1989, and wrotefinish[answer]as well. - A search miss, then the wrong number. On question 5 the search for Genghis Khan's birth year returned two paragraphs that do not give it, and the model subtracted 1483 from 1546, the year Luther died according to its previous search. On question 7 one search returned neither Harvard's founding year nor the paragraph that holds it, and the model computed 1890 − 1892, two years from the University of Chicago's paragraph, and answered 2.
- Wrong reasoning on right facts. On question 2 it found the 24–10 score and answered with the score instead of the margin, and on question 8 it had both dates in 1963 and still picked Kenya's independence, the later one.
The two right answers, the Apollo 11 and Levi's Stadium questions, each took two searches and one calculation, and in both the model also wrote Finish[…] without Action: first, was told the action was invalid, and then finished properly. Without tools the model answered every question with a number or a phrase that was wrong, such as 150 years between Tesla and Luther, so even this small model gains from tools when it reads their results.
Where it came from
ReAct follows chain-of-thought prompting (Wei et al., 2022), which showed that writing intermediate steps before an answer helps large models, and turns those steps into a dialogue with the world. Toolformer (Schick et al., 2023) taught a model to insert API calls into its own text during training. Reflexion (Shinn et al., 2023) adds a written reflection after a failed run and tries again with it. Later chat models were trained on a structured format for calls instead of text actions, which the Tool calling tab shows; the CodeAct tab replaces the action with Python code, and the MCP tab serves the tools from a separate process.
Papers
- ReAct: Synergizing Reasoning and Acting in Language Models The method: interleaved Thought, Action and Observation steps, with search and finish actions on question answering, and an analysis of its failures.
- Qwen3 Technical Report The model recorded here, with its thinking mode switched off.
- Chain-of-Thought Prompting Elicits Reasoning in Large Language Models Writing intermediate steps before the answer, which ReAct's Thoughts build on.
- Toolformer: Language Models Can Teach Themselves to Use Tools A model trained to insert calls to a calculator, search and other APIs into its own text.
- Reflexion: Language Agents with Verbal Reinforcement Learning Retries a failed ReAct run with a written reflection on what went wrong.
- SQuAD: 100,000+ Questions for Machine Comprehension of Text The Wikipedia paragraphs the search tool returns.
- C-Pack: Packed Resources For General Chinese Embeddings The BGE embedding models, among them bge-small-en-v1.5, which embeds the search queries.