Context management for Claude agents — Transcript
Full transcript
- 0:01Every request that you send Claude has a
- 0:03context window.
- 0:04A million tokens sounds like a lot, but
- 0:06it runs out faster than you think once
- 0:08you're shipping a real agent. And this
- 0:10is where contact management comes in.
- 0:12It's how you stay inside the window
- 0:14without losing what matters.
- 0:17Context is everything Claude sees on a
- 0:19given turn. The system prompt, the
- 0:21message history, tool definitions, tool
- 0:23results, attached files, skills,
- 0:25thinking blocks. It's the input to every
- 0:27single API call. You pay for it on the
- 0:30way in and you pay for it on the way
- 0:31out. And once it's full, the request
- 0:33fails. So, the goal isn't fit
- 0:35everything. The goal is fit the right
- 0:37things in.
- 0:39Anthropic publishes four patterns for
- 0:41managing context in long-running agents.
- 0:43Three are first-class API features and
- 0:45one is a design pattern. One is the
- 0:47just-in-time context. Don't load
- 0:50everything up front. Load what the agent
- 0:52needs now and let it pull more in via
- 0:54tools when it asks. The compliance
- 0:57review agent doesn't get the entire
- 0:58building codebook in a system prompt. It
- 1:01calls lookup building code when it needs
- 1:03a section.
- 1:05When a conversation runs long, Anthropic
- 1:07server-side compaction summarizes older
- 1:09turns into a single block. Add a context
- 1:11management key that holds a edits and
- 1:14then a type. Just like this. The API
- 1:17auto summarizes when input crosses the
- 1:18trigger threshold. Prompt caching lets
- 1:21you mark stable parts of the request.
- 1:23The system prompt, the tool definitions,
- 1:25a long document, and reuses them across
- 1:27calls at a fraction of the cost. So, if
- 1:29your system prompt is 4,000 tokens and
- 1:31you call it 100 times an hour, well,
- 1:33caching is a difference between a usable
- 1:35bill and a phone call from finance. Some
- 1:38context needs to survive across
- 1:39sessions. User preferences, the agent's
- 1:42running notes, what was decided last
- 1:44week. The recommended primitive is the
- 1:45memory tool. Claude reason writes a
- 1:47memories directory via tool calls. You
- 1:50implement the storage back end client
- 1:51side. So, this could be like a file
- 1:53system, database, encrypted store,
- 1:55whatever you want. Anthropic auto
- 1:57injects a system instruction telling
- 1:58Claude to check the memory directory
- 2:00before starting work. In a production
- 2:02app, you'll usually layer all four at
- 2:04once.
- 2:05The compliance review agent caches a
- 2:06system prompt and tool definitions and
- 2:09pulls building code sections in just in
- 2:10time via lookup building code. And each
- 2:13pattern handles a different failure
- 2:14mode. Cost, window size, statelessness,
- 2:17pick the ones that match what's
- 2:18breaking.
- 2:23Context isn't free and it isn't
- 2:25infinite.
- 2:26Load just in time.
- 2:28Compact what's old.
- 2:30And remember what has to survive across
- 2:32sessions.
- 2:34Four patterns but one goal.
- 2:36Either wire these up by hand or use
- 2:38Claude managed agents which ship with
- 2:39caching and compaction on by default.
About this transcript
This page contains the full transcript of Context management for Claude agents by Claude, generated from the public captions YouTube serves with the video. The transcript has 467 words across 79 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.