Context Is a Budget
When an agent loses the thread, the instinct is to give it more context. Anthropic's engineering team argues the opposite: don't ask how to give your agent more context — ask how to give it the right context.
When an agent loses the thread, the instinct is to give it more context. Anthropic's engineering team argues the opposite: don't ask how to give your agent more context — ask how to give it the right context.
Three terms first. The context window: everything the model sees at once, from instructions and tools to history and data. Context rot: as that window fills, the model recalls what's in it less accurately. Context engineering: choosing what goes in, every time the model is called.
Picture the context window as a tray. Everything the model sees has to fit in it — instructions, tools, message history, any data it pulls in — and an agent working in a loop keeps adding to that tray with every tool call and every result. But more isn't better: as the tray fills, recall gets less accurate, not more. Why? Attention is a budget. Every token attends to every other token, so n tokens make n-squared pairs — add more, and each one gets a thinner share. The goal is the smallest set of high-signal tokens that gets the job done: a clear prompt, a few tools that don't overlap, a handful of good examples instead of a laundry list of edge cases.
Loading strategy matters too — don't load everything up front. Keep lightweight references, like file paths and links, and load data just in time; Claude Code does this with commands like head and tail to read big data without pulling in all of it.
Long tasks outgrow any tray, and three fixes handle that. Compaction: near the limit, history gets summarized, keeping decisions and unresolved bugs while dropping redundant tool outputs, and a fresh window starts from that summary. Structured note-taking: the agent writes notes to a file outside the window, like a to-do list, and reads them back after a reset. Sub-agents: the main agent keeps the plan and hands focused jobs to sub-agents with clean windows — each may burn tens of thousands of tokens exploring, but returns only a condensed summary, often one to two thousand tokens.
Whichever fix applies, the rule is the same: context is a budget. Spend it on the smallest set of high-signal tokens that gets the next step right.
Your Turn: Paste into Claude: "Here's a long task I run with an AI agent: [describe it in two sentences]. List everything that lands in its context. Mark each item: keep, load only when needed, compact, move to a notes file, or hand to a sub-agent. Then write the summary you'd keep if the context reset right now." Then check two things yourself: for each item kept, does the next step actually use it — if not, cut it — and paste only the summary into a fresh chat to see if Claude can say what's done and what's next.
Source: Anthropic, "Effective context engineering for AI agents" — anthropic.com/engineering/effective-context-engineering-for-ai-agents
0:00 The question, and three terms 0:25 The context window as a tray 0:47 Attention is a budget; keep the high signal 1:07 Load it just in time 1:20 Compaction 1:35 Note-taking, sub-agents, and the rule 2:07 Your turn
Part of the Claude & Agentic AI series. @NikBearBrown
Deliberately Not Claimed
This video summarizes concepts and fixes as described in Anthropic's own published engineering post and does not claim to introduce new techniques or supersede that source. It does not claim these three fixes (compaction, note-taking, sub-agents) are the only valid approaches, or that they apply identically to every agent framework. Check the linked source for the full, authoritative treatment.
Production Credits
Fully AI-generated production — no human-performed audio or video.
Narration: Liam (Kokoro am_onyx) Animation & motion graphics: Manim, Remotion Credit line: @NikBearBrown Hashtags
SEO Keyword Tags
context engineering, context window, context rot, AI agent context, effective context engineering, Claude Code compaction, structured note-taking AI, sub-agents context, attention budget LLM, Anthropic context engineering, long-running AI agents, LLM token budget, agentic AI context management, Claude agents tutorial, AI agent memory management
What this video covers
- 0:00 — The question, and three terms 0:25 The context window as a tray 0:47 Attention is a budget; keep the high signal 1:07 Load it just in time 1:20 Compaction 1:35 Note-taking, sub-agents, and the rule 2:07 Your turn
Transcript
A lightly formatted transcript of the video, with timestamps so you can jump to any section on YouTube.
The question, and three terms 0:25 The context window as a tray 0:47 Attention is a budget; keep the high signal 1:07 Load it just in time 1:20 Compaction 1:35 Note-taking, sub-agents, and the rule 2:07 Your turn
[0:00] Ciao, this is Liam in for Bear. When an agent loses the thread, the instinct is to give it more. So, don't ask how to give your agent more context, ask how to give it the right context. Three terms: the context window, everything the model sees at once from instructions and tools to history and data. Context rot, as that window fills the model recalls what's in it less accurately. And context engineering, choosing what goes in every time the model is called. Picture the context window as a tray. Everything the model sees has to fit in it. The instructions, the tools, the message history, and any data it pulls in. An agent working in a loop keeps adding to it. Every tool call, every result lands in the tray. But more isn't better. As the tray fills, the model recalls what's inside less accurately. Anthropic calls this context rot. Why? Attention is a budget. Every token attends to every other token, so
N tokens make n squared pairs. Add more and each one gets a thinner share. So, the goal is the smallest set of high signal tokens that gets the job done. A clear prompt, a few tools that don't overlap, a handful of good examples, not a laundry list of edge cases. Next, don't load everything up front. Keep lightweight references like file paths and links, and load the data just in time. Claude code does this using commands like head and tail to read big data without loading all of it. Long tasks outgrow any tray, and Anthropic describes three fixes. First, compaction. Near the limit, the history gets summarized. In Claude code, that keeps decisions and unresolved bugs, and drops redundant tool outputs. Then a fresh window starts from the summary. Second, structured note-taking. The agent writes notes to a file outside the window like a to-do list. After the context resets, it reads them back and carries on. Third, sub-agents. The main agent
Keeps the plan and hands focused jobs to sub-agents with clean windows. Each may use tens of thousands of tokens exploring, but returns only a condensed summary, often 1 to 2,000 tokens. Whichever you use, the rule is the same. Context is a budget. Spend it on the smallest set of high signal tokens that gets the next step right. Your turn. Paste this into Claude. Here's a long task I run with an AI agent. Describe it in two sentences. List everything that lands in its context. Mark each item. Keep load only when needed. Compact. Move to a notes file or hand to a sub agent. Then write the summary you'd keep if the context were set right now. Then check two things yourself. For each item you kept, does the next step use it? If not, cut it. And paste only the summary into a fresh chat. Can Claude say what's done and what's next? Context is a budget at Nick Bear Brown.





