Back to blog

AI for beginnersGuide

Why an AI agent re-reads its whole history on every step

A Claude Code status-line fix shows why long agent sessions get expensive: every call re-sends the conversation. Estimate the cost and cut it.

By CheapTokens TeamPublished 5 min read

Cover: why an AI agent re-reads the whole chat at every step
On this page
  1. A status line that re-read everything
  2. Why every step re-sends the history
  3. What it costs: one task, one day
  4. Four ways to cut it
  5. The notes pattern

Your agent ran for ten minutes, and the bill is bigger than the task looks. Almost always the reason is the same: the model remembers nothing between calls, so every step sends the whole conversation so far as input again. A 50-step session pays for its first messages 50 times, which is why the cost grows faster than the work done.

A fix that Anthropic announced for Claude Code on 4–5 November 2026 shows this in one small place. Below: what changed, the arithmetic of a 50-step loop, and what you can do about it.

A status line that re-read everything#

Claude Code can start background subagents: helper agents that work on a side job while you carry on. Each one shows a one-line status, something like 'running tests, 3 of 8 done'.

The ClaudeDevs account on X announced the change (the post is dated 5 November 2026; secondary reports say 4 or 5 November). The status used to refresh every 30 seconds, and each refresh re-read the subagent's entire conversation. Now Haiku 5.5 writes the status from short notes, and Anthropic puts that at about 99% cheaper per update. That is a per-update figure, not a per-session one: the subagent's real work still reads its history.

Picture what the old way meant. Say a subagent has 60,000 tokens of conversation by minute twenty. The status itself is maybe 30 tokens. But to write those 30 tokens the model had to read all 60,000 again, twice a minute, for as long as the subagent ran.

Before the fix the status re-read the whole conversation every 30 seconds; after it, short notes
The status-line change as described in the ClaudeDevs announcement, 5 November 2026

Nobody needs the full transcript to say 'running tests'. A few lines of notes (what I'm doing, what is finished) are enough. That is the whole fix: give a side task the notes, not the transcript.

Why every step re-sends the history#

Think of a letter to someone who forgets you the moment they reply. To continue, you send the whole correspondence again plus the new line. An agent step is exactly that call: the system prompt, your task, every earlier answer and every tool result go in again. (The chat version of this story is in why a long AI chat costs more.)

Let's put numbers on it. Say the system prompt and the task take 3,000 tokens, and each step adds about 2,000 (the model's reply plus the tool output it reads). Step n then sends 3,000 + 2,000 × n tokens: 5,000 at step 1, 23,000 at step 10, 103,000 at step 50.

Input tokens per step in the example agent grow from 5,000 to 103,000
Input size per step in the example agent (assumed 3,000 start, +2,000 per step)

Guess the number

How many input tokens does step 50 of this agent send?

Show answer

Answer: 103,000

3,000 + 2,000 × 50 = 103,000. The model re-reads the start prompt and all 49 earlier steps, then your new step on top.

Now add up all 50 steps. The growing part is 2,000 × 1,275 = 2,550,000, where 1,275 is 1 + 2 + … + 50. The starting prompt, sent every time, is 50 × 3,000 = 150,000. Together: 150,000 + 2,550,000 = 2,700,000 input tokens. The finished conversation holds only 103,000. You pushed 2.7 million tokens through the model to get a 103,000-token transcript, and the bill follows the first number.

What it costs: one task, one day#

Price the same 50-step agent on DeepSeek-V4-Flash. The average step sends 54,000 tokens, so 54,000 × 50 = 2,700,000 input tokens in total, and it writes about 400 per step (400 × 50 = 20,000). The whole task costs $0.0425. Here is the same workload on every model we have, next to OpenRouter:

Model Per request 50 requests OpenRouter, 50 requests
GLM-5.3-Flash $0.0011 $0.0548 $0.0921
DeepSeek-V4-Flash $0.00085 $0.0425 $0.192
MiniMax-M2.7 $0.0028 $0.138 $1.66

54,000 input and 400 output tokens per request. Prices per 1M tokens are current and change together with our tariffs; the OpenRouter column shows reference prices for the same workload.

In the table, every model is cheaper than OpenRouter in total, with input and output counted together.

Now the status line. 120 updates is an hour of one subagent, and each writes about 30 tokens (30 × 120 = 3,600 output). The old way: 60,000 × 120 = 7,200,000 input tokens, more than two and a half of the 50-step tasks above, spent on nothing but a status text. With a 500-token note it is 500 × 120 = 60,000. On GLM-5.3-Flash that is $0.144 against $0.0013.

Try your own agent: tokens per step, steps and tasks per day.

Cost calculator

A day of ten such tasks

Input tokens per request: 54,000 · Output tokens per request: 400 · Requests per day: 500

ModelPer dayPer month
GLM-5.3-Flash$0.548$16.44
DeepSeek-V4-Flash$0.425$12.75
MiniMax-M2.7$1.38$41.40

Base URL, key and a first request are in the CheapTokens docs; current prices for every model are on the pricing page.

Four ways to cut it#

None of these needs a special tool. It is a habit of asking: does this call really need the history?

The notes pattern#

Keep a few lines of notes while the agent works, and hand only those to a small model when you need a status or a summary. Here it is on GLM-5.3-Flash (zai-org/GLM-5.3-Flash, 390K context, up to 8,192 output tokens per answer):

python
import os
from openai import OpenAI

client = OpenAI(
    base_url='https://api.cheaptokens.dev/v1',
    api_key=os.environ['CHEAPTOKENS_API_KEY'],
)

notes = [
    'Task: fix failing tests in billing/',
    'Done: found 3 failing tests, fixed 2',
    'Now: running the third test',
]

reply = client.chat.completions.create(
    model='zai-org/GLM-5.3-Flash',
    max_tokens=100,
    messages=[
        {'role': 'system', 'content': 'Write a one-line status from the notes.'},
        {'role': 'user', 'content': '; '.join(notes)},
    ],
)
print(reply.choices[0].message.content)
print(reply.usage.prompt_tokens, reply.usage.completion_tokens)

You get back one short line, and the usage pair shows input in tens of tokens, not tens of thousands. That is the same idea as the Claude Code change, in a dozen lines.

Which habit fits your case?

Pick your case

What is your situation?

One session, the topic changed

Start a fresh session. Paste five lines of notes (goal, what is done, what is next) instead of the old transcript. The trimming options are in trim chat history: sliding window or summary.

A side job: status, summary, title

Give it the notes, not the history, and send it to a small model, as in the code above.

Huge tool output: logs, test dumps

Keep it out of the history. Show the last 20 lines or the one failing test, not the whole dump: every line you keep is re-sent on every later step. Claude Code token usage: keep tool output out of context shows how.

The same long prompt on every call

Ask your provider about prompt caching, which can reuse a repeated start of the prompt instead of reading it fresh each time.

If you use Claude Code, update it and look through the changelog for the status-line note.

For the loop itself, DeepSeek-V4-Flash (deepseek-ai/DeepSeek-V4-Flash-0731) gives you a 380K context, up to 32,768 output tokens per answer and one price at any hour. The 103,000-token end of our example fits in that window more than three times over. For notes and summaries, GLM-5.3-Flash. Other models are on the models page.