🎉 Giảm 20% cho đơn hàng đầu tiên!✦🚚 Miễn phí vận chuyển cho đơn trên 500.000₫✦⚡ Flash Sale — Số lượng có hạn!✦🎁 Quà tặng kèm cho đơn từ 1.000.000₫✦🎉 Giảm 20% cho đơn hàng đầu tiên!✦🚚 Miễn phí vận chuyển cho đơn trên 500.000₫✦⚡ Flash Sale — Số lượng có hạn!✦🎁 Quà tặng kèm cho đơn từ 1.000.000₫✦
Anthropic and How to Keep an AI Agent Running 50 Steps Without Overloading Memory: Cutting Context From 180,000 to 5,000 Tokens — Real or Just a Viral Document?
Quay lại Blog

Anthropic and How to Keep an AI Agent Running 50 Steps Without Overloading Memory: Cutting Context From 180,000 to 5,000 Tokens — Real or Just a Viral Document?

30 tháng 11, 202613 phút đọcVũ Khôi
English
#English#AI Agent#Lập trình
Vũ Khôi

Vũ Khôi

Tác giả tại Wotech Electronics Blog

Dario Amodei, CEO of Anthropic, during an interview

Anthropic and How to Keep an AI Agent Running 50 Steps Without Overloading Memory: Cutting Context From 180,000 to 5,000 Tokens — Real or Just a Viral Document?

An AI agent working through 50 steps faces a familiar problem: the longer it works, the more conversation history and results from earlier steps it must carry — by the end, context can swell to 180,000 tokens. A viral document called "Harness Notes" (November 2026), titled "Context Compaction: 50 Steps in a Flat Window", claims Anthropic's engineers solved this by keeping context stable around 5,000 tokens — same task, same model. This article presents the 6 components of that architecture — and states clearly which parts are verified and which are not.

Quick answer: Read carefully before believing the 180,000 → 5,000 token figure. The "Harness Notes" document circulating on social media (November 28, 2026) has NO verified Anthropic origin — no link to an original post, no Anthropic paper or official document by that name; a fact-check posted the same day pointed out several contradictions (see "What Is Verified" below). So this article does NOT present 180,000 → 5,000 tokens as a verified measurement. What is real and worth learning are the 6 design patterns in the document — writing state to disk, keeping context flat with a running summary, checkpointing and resetting on a fixed interval, using a small model to summarize, a replay log, and turning repeated work into skills — because they match what Anthropic has actually published on context engineering: the phenomenon of "context rot", the "just-in-time context" principle, subagents returning 1,000–2,000 token summaries, and Claude Code's compaction mechanism. Read the 6 patterns as a good design to reference, not the 5,000-token figure as a guarantee.

Context is all the text the AI model re-reads at each step of its work: system instructions, conversation history, tool results already called. The context window is the length limit of that text. Context compaction is the technique of compressing history into a short summary so the agent can keep working without carrying its entire past. Context rot is Anthropic's name for the phenomenon of answer quality degrading as context grows — a model recalls worst in the middle of a long input.

The "Harness Notes" document page, November 2026: "Context Compaction: 50 Steps in a Flat Window" — the six parts and a 20-line prompt

What does the "Harness Notes" document say?

According to the document's abstract: a long-running agent appends every step's result to its context, so a 50-step run drags roughly 180,000 tokens through the model by the end, and quality falls as the window fills. Anthropic's engineers — according to the document — kept the window flat: every result is written to disk, the context holds a running summary, and the agent compacts and resets on a fixed interval. The window stayed near 5,000 tokens at step 5 and at step 50. Same task, same model. The document lays out 6 parts and a 20-line prompt to set them up in Claude Code:

  1. State to Disk. Every step result and data item is written to a ./state folder (e.g. step_01.json, step_02.json...). Instead of holding all content in context, the agent only keeps a short identifier to reference the data when needed.
  2. Flat Window. Context holds only a running summary of the work in progress, instead of the whole conversation history. That keeps context around 5,000 tokens, whether at step 5 or step 50.
  3. Checkpoint and Reset. Every 10 steps, the agent runs a context-compaction cycle: summarize the important information, drop history that is no longer needed, reload the summary to continue. Context no longer grows continuously over time.
  4. Cheap Recap. A smaller AI model is used to write the summary. The big model only needs to read that summary to continue, instead of spending resources re-reading the whole history.
  5. Replay Log. The agent records progress in a run.log file. If execution is interrupted or fails, the agent can resume from the completed step and continue without redoing earlier work.
  6. Skills. Recurring sub-tasks are saved as callable code (e.g. ./skills/parse-invoice.ts, dedupe-rows.ts with a SKILL.md). On the next run, the agent already has a toolbox instead of rebuilding everything from scratch. All code runs in a sandbox with time and memory limits.

The accompanying prompt ("CONTEXT COMPACTION — FABLE 5.2", 20 lines) packages the 6 rules into variables {TASK}, {STEP BUDGET}, {COMPACT EVERY} — a specification for users to implement themselves, not a paste-and-run command.

What is verified, and what is not?

This is the most important part of the article — and the reason the title has a question mark. Wotech checked this document through independent search, with these results:

Not verified — treat as unproven:

  • Anthropic origin: no Anthropic paper, document or page named "Harness Notes" or "Context Compaction: 50 Steps in a Flat Window" could be found. The viral posts (Instagram, Facebook, November 28, 2026) are all screenshots of a single document page, with no link to an original. Several commenters asked for the source link and called the document AI-generated content, with no evidence of authorship.
  • The 180,000 → 5,000 token figures: no measurement accompanies them. A fact-check (Facebook, Joe Proveaux, November 28, 2026) pointed out an internal contradiction in the document itself: the abstract says the "naive" run drags 180,000 tokens, but chart (b) on the same page labels the naive run "13,007" versus "flat 5,000" — two numbers that don't match, with no explanation for the difference. The fact-check also questioned the math behind the "flat 5,000 tokens" claim and the "same task, same model" assertion, given no experimental description.
  • A prompt that self-resets or switches models mid-session: the fact-check notes that a prompt cannot self-reset a model or switch models mid-session — what the 20-line prompt describes is a system (harness) design to be implemented in code, not a command you paste into Claude Code and run.

Verified — what Anthropic has actually published, matching the 6 design patterns:

  • Context rot is real: Anthropic's engineering writing on context engineering names the phenomenon of quality falling as context grows, treating every token as drawing down a finite attention budget. The "lost in the middle" research also shows models recall worst in the middle of long inputs.
  • Just-in-time context: Anthropic calls this the strongest pattern — agents hold lightweight pointers in context (paths, symbols, queries) and load contents just when needed, the way Claude Code analyzes large data with head and tail instead of loading whole files.
  • Subagents return summaries: Claude Code's docs recommend delegating investigation to subagents — a subagent may burn tens of thousands of tokens exploring but returns only a 1,000–2,000 token distilled summary to the main session. That is the "Cheap Recap" idea, except Anthropic uses subagents rather than "a small model".
  • Compaction exists in Anthropic's systems: per the API docs, when input tokens reach a trigger (150,000 by default, never below 50,000), the API pauses, has the model write a summary of the transcript, and continues from that summary. In Anthropic's cookbook, a research agent reading eight documents climbed to 335,279 tokens across five turns; compaction set to trigger at 180,000 fired once at turn four and replaced the prior turns with a summary of about 2,800 tokens. Claude Code also has PreCompact/PostCompact hooks: one fires before the transcript is summarized so state can be written to disk, and one fires after with the summary in hand so it can be logged or restored — almost exactly the "State to Disk" and "Replay Log" of the viral document.
  • Fresh windows for long work: Anthropic reports that for long-running work, compaction alone wasn't enough — they moved to a fresh window per feature, with a progress file. That is the practical version of "Checkpoint and Reset".

In other words: the 6 design patterns are sound and grounded in Anthropic's official documentation — but the 180,000 → 5,000 token figures and the "Anthropic" label on the viral document are unverified. This article presents the patterns for their practical value, and states this boundary clearly so readers don't quote the numbers as measured results.

The 6 design patterns — when to use which?

Component Problem it solves The price you pay When to use it
State to Disk Context swells because it holds all results Must re-read files when details are needed Every long-running agent: write each step's result to a file, keep only the id in context
Flat Window Conversation history fills the window Detail is lost in the summary When the agent must run dozens of steps or more
Checkpoint & Reset Context grows endlessly over time Each reset costs one summarization On a fixed schedule (e.g. every 10 steps); don't wait until the window is nearly full
Cheap Recap The big model is expensive when re-reading history The summary may drop details Use a small model (or subagent) to summarize; the big model only reads the summary
Replay Log A mid-run crash means starting over Must log every step Every long task with expensive steps (API calls, long test runs)
Skills Repeated work must be rebuilt each time Must invest in writing and maintaining skills From the second time a sub-task appears

The original post's viewpoint is also worth keeping: the future of AI agents lies not only in intelligence, but in how they remember. Humans don't need to remember every sentence or every action over years — we take notes, save documents, build processes and look things up when needed. A good agent isn't one that tries to remember everything, but one that knows what to keep in mind, what to store in long-term memory, and when to retrieve it. Competition between AI agent systems won't only be about which model is smarter, but about which system can work longer, cost less, never lose state, and accumulate experience across many runs.

Apply it now

  • Use your harness's built-in features before building your own: Claude Code already has automatic compaction and /clear between tasks; the docs advise using subagents for investigation so large file reads don't pollute the main session. Learn /compact and subagents before buying or building a separate "context engine" — below a few hundred thousand lines of code, a short memory file plus automatic compaction usually beats a bespoke RAG stack.
  • Write state to disk from step 1: in your agent, each step writes its result to ./state/step_<n>.json and keeps only the id + one line of description in context. When details are needed, read the file back — Anthropic's just-in-time context principle.
  • Set a fixed checkpoint schedule; don't wait until full: e.g. every 10 steps, summarize state, drop old history, reload the summary. Changing history, even helpfully, breaks the cache — so clean up rarely, and decisively each time.
  • Let a small model (or subagent) write the summary: the big model only reads the summary. Anthropic measured subagents returning 1,000–2,000 token summaries after burning tens of thousands of tokens exploring — that is real savings, without needing the viral document's 5,000-token figure.
  • Keep a replay log for every long task: each step logs its inputs + id to run.log; on crash, resume from the last logged step, repeat nothing. This is the cheapest and most useful of the 6 patterns.
  • Turn repeated work into a skill from the second time: when a sub-task appears a second time, save it as callable code with a short description — next run, the agent already has a toolbox.
  • Don't copy the 20-line prompt and expect it to run itself: the prompt in the document is a design specification, not a ready recipe. It needs harness code to execute the disk writes, summarization and resets — and no prompt can switch models mid-session.

Frequently asked questions

1. Is "Harness Notes" an official Anthropic document? No evidence. No Anthropic paper or document by that name could be found, and the viral posts carry no link to an original. A fact-check dated November 28, 2026 questioned its origin and its numbers. This article presents the 6 design patterns because they match Anthropic's official documentation, not because the "Anthropic" label on the viral document is verified.

2. Are the 180,000 → 5,000 token figures real? Unverified — no measurement or experimental description accompanies them, and the document contradicts itself (the abstract says 180,000 tokens, the chart on the same page says "naive 13,007"). A more trustworthy figure comes from Anthropic's official cookbook: compaction replaced prior turns with a summary of about 2,800 tokens in a run that climbed to 335,279 tokens.

3. What is context rot? Anthropic's name for answer quality degrading as context grows — a model recalls best at the beginning and end of a long input, worst in the middle. That is why keeping context small and "fresh" matters more than having a big window.

4. Should I copy the 20-line prompt from the document? Read it as a design specification, not a ready recipe. It needs harness code to execute disk writes, summarization and resets — and a prompt cannot self-reset a model or switch models mid-session. Starting from Claude Code's built-in compaction and subagents is cheaper and more reliable.

5. What is the cheapest way to run a long agent without context bloat? Three things, in order: write each step's result to a file and keep only the id in context; use subagents for investigation and take only their 1–2 thousand-token summaries; set a fixed-interval checkpoint summary. All three are in Anthropic's and Claude Code's official documentation.

Source: post by the page "Học lập trình cho người mới bắt đầu" on Facebook (November 29, 2026), summarizing the "Harness Notes" document (November 2026), "Context Compaction: 50 Steps in a Flat Window". Wotech verified it through independent search: NO verifiable Anthropic origin was found for this document (no original link, no official paper), and a fact-check dated November 28, 2026 (Joe Proveaux) pointed out internal contradictions (180,000 tokens in the abstract vs "naive 13,007" in the chart) and other problems — the 180,000 → 5,000 token figures in this article are presented as the document's unverified claims, not measured results. In contrast, the 6 design patterns match Anthropic's official context-engineering documentation (context rot, just-in-time context, subagents returning 1,000–2,000 token summaries, API compaction triggering at 150,000 tokens, PreCompact/PostCompact hooks, cookbook: a ~2,800-token summary in a 335,279-token run) and Claude Code's documentation — Wotech cross-checked and states this boundary in the article. The cover photo is of Dario Amodei, CEO of Anthropic; the mid-article image is the "Harness Notes" document page attached to the original post.