MachineRoom

Machine Room · 15 Oct 2026 · 9:16

What Claude Code Is Actually Doing When It Says "Thinking"

Watch on YouTube

A language model does one thing: it reads the context window and writes one token. Extended thinking (the "Thinking…" counter in Claude Code and Codex) is that same next-token loop, run before the reply into a thinking block the reply then reads back. This episode walks through the mechanism one step at a time.

The worked example is the famous 2024 failure, "how many r's are in strawberry": with thinking off the model answers from one forward pass over a couple of tokens and says two; with thinking on it spells the word out in the thinking block, one letter per pass, and counts three. Then the bill and the dial: every thinking token is billed as an output token, and the effort setting (Claude Code's effort, Codex's model_reasoning_effort) sets how long the model keeps writing before it commits. Then where the habit came from: chain-of-thought prompting (2022), OpenAI o1 (September 2024), and DeepSeek-R1-Zero (January 2025), trained by reinforcement learning on a reward for right answers alone, whose responses grew from hundreds to thousands of tokens while AIME 2024 accuracy rose from 15.6 % to 71.0 %, and which wrote "Wait, wait. Wait. That's an aha moment I can flag here."

Chapters

  1. 0:00Thinking…: what the counter is counting
  2. 0:42One Pass, One Word: next-token prediction and tokens
  3. 2:58Writing Before the Answer: the thinking block and effort
  4. 5:44Nobody Taught It "Wait": reinforcement learning in DeepSeek-R1
  5. 8:08Back at the Terminal: summaries, cost and the effort dial

Notes

"straw" + "berry" is an illustration of how a tokenizer chunks a word; real tokenizers split differently. Claude Code effort defaults are from the official model-config docs as of October 2026 (Fable high, Opus 5.5 medium, Sonnet 5.5 medium). The 78,000 / 47,000 token figures are Claude Fable 5.1's average output and reasoning tokens per task in Artificial Analysis's comparison.

Sources

Previous episode, how Starlink routes through space: https://youtu.be/aEokWFY_WxU

Get the next one by email

One email per video, with the sources. No newsletter padding, no selling the list. Leave any time.

Transcript

The narration, word for word, from the subtitle file that ships with the video.

0:00Thinking…: what the counter is counting

You type a question into Claude Code. It says thinking. Codex says the same. Ten seconds, forty seconds, sometimes two minutes. So what is the model doing in there, exactly? Is it searching? Running code? Talking to itself? This video walks through it one step at a time: what the model does in a single step, what thinking adds to that step, and where the thinking habits came from. By the end, when you watch that counter, you will know exactly what it is counting. Everything the model does happens in one small loop, so start there.

0:42One Pass, One Word: next-token prediction and tokens

Here is the only thing a language model ever does. The model reads the context window: your message, the conversation so far, and whatever the model itself has written so far. Then the model produces one word. The model puts that word at the end of the context window, reads the whole context window again, and produces the next word. Read, then one word. That loop is the entire machine. One trip around that loop is a pass. Each pass does a fixed amount of work. The model cannot take longer on a hard word than on an easy word. Same computation, every single word. Now the worked example. You type into Claude Code: how many r's are in strawberry. Thinking off. Thinking off means the very next word the model writes is the answer. The model gets exactly one pass to produce that word, the same amount of work it spends writing a word like the. There is no counting inside one pass. The number that comes out is a guess from memory. And here is why the guess was two. The model does not read letters. The model reads words in chunks, called tokens. Strawberry reaches the model as two chunks: straw, and berry. The model has never seen the ten letters laid out one by one. The model does know how strawberry is spelled; the model has read the word spelled out thousands of times. Writing the letters down is easy. Counting them without writing them down, in one pass, is not. To count the r's, the model would first have to spell the word out, letter by letter, and spelling takes passes. With thinking off, there are no passes before the answer. So the model answers from what it remembers about the two chunks, and a chunk does not carry a letter count. Two. The model never saw the letters. So the fix is not a smarter model. The fix is room.

2:58Writing Before the Answer: the thinking block and effort

Room comes from the same loop. The model is allowed to write words that are not the answer yet, into a separate block that comes before the reply. That block is the thinking block. Every word in the thinking block is made exactly the way an answer word is made: read the context window, produce one word. The thinking block is not a different engine. There is no other engine. What changes is what the next pass can see. When the model writes s, t, r, a, w into the thinking block, each letter goes in as its own chunk. For the first time the letters of strawberry are sitting in the context window, one by one, and the next pass reads them back. The model's own scratch work becomes part of what the model reads. Strawberry again, thinking on. Claude Code says thinking. In the block, the model spells the word out, one letter at a time, and counts the r's as it goes: one, two, three. Then the block closes. Now the reply. The first word of the answer comes from a pass that can see the spelled-out word and the count, sitting right there in the context window. The answer is three. That is all thinking is. A hard problem needs more steps than one pass can hold, so the model spends passes writing the steps down, and the reply reads them back. The context window is the model's working memory. Two things follow, and both show up on your screen. First, every thinking word is a pass, and every pass is billed as an output token. On a hard task Claude Fable writes about seventy-eight thousand tokens, and forty-seven thousand of those are the thinking block. You pay for every one. Second, the dial. Claude calls it effort. Codex calls it reasoning effort. A few levels each. The dial does not change the model. The dial changes how long the model is willing to keep writing before it commits to an answer. In Claude Code today, Fable runs at high, Opus at medium, Sonnet at medium. Turn the dial up and the block gets longer. The counter you watched in the open is that block being written. The dial buys room, and room costs words. But nobody wrote spell the word out first. So where did the model learn to do that?

5:44Nobody Taught It "Wait": reinforcement learning in DeepSeek-R1

Nobody wrote the spelling step. Before twenty twenty-four, a model only wrote steps if you typed let's think step by step. And the steps were often confident and wrong, because the model had been trained to write text that looks like reasoning, never to get the answer. In September twenty twenty-four OpenAI released o1, the first model trained to think before answering. OpenAI did not say how. In January twenty twenty-five, DeepSeek published how. A model they called R1-Zero, trained from the plain model, before any chat training, with no examples of good reasoning shown to the model at all. The training was one method. Give the model a math problem, let the model write whatever it wanted, and scored the response on two things only: was the final answer right, and did the model put its thinking in the right box. That was the whole reward. Nobody wrote a rule that said spell it out, check your work, or try another way. Over the training, the responses grew. Hundreds of words at the start. Thousands by the end. The model learned, on its own, that writing more before answering earned more right answers. The accuracy climbed with the length. On a hard math test the model went from sixteen percent right to seventy-one percent right, same model at the start, nothing added but the training. Then the moment the DeepSeek team put in the paper. Partway through training, in the middle of a solution, the model wrote: Wait, wait. Wait. That's an aha moment I can flag here. And then the model went back and redid the step. The paper's words: re-checking previous steps and trying other approaches arise spontaneously. Nobody put them in. They survived, because a model that re-checks gets more answers right. Longer, then righter. So the habits you see in a thinking block, restating, trying a route, backing up, are not instructions. They are what a reward for right answers left behind.

8:08Back at the Terminal: summaries, cost and the effort dial

Back to Claude Code and Codex, both on thinking, the counter climbing. Now you know what the counter counts: passes, one word each, into a block the reply will read back. What is on your screen is not that block. Claude Code shows you a summary, or nothing. The raw text is never sent. OpenAI has shown a summary since o1. The block exists and is billed either way. The dial is yours. A rename or a one-line fix does not need room. A refactor across ten files does. Turn the dial down and you pay for fewer passes. Turn it up and the model can spell the problem out before it commits. When you do read the thinking, read it for the steps. The block is scratch work, and a wrong turn in scratch work is visible early. If the block is heading into the wrong file, you can stop the run before the reply. The model is writing, and you are watching the writing.

Visuals are code-rendered motion graphics, no stock footage, no AI imagery. Narration is synthetic. How it's made.