Agents and Workflows·Task 1.3·Bloom: apply·Difficulty 3/5·9 min read·Updated 2026-07-12

Agent Memory and Context-Window Management for the CCDV-F Exam

Agent Patterns and Frameworks (4.9%): Common agent design patterns (tool-use loops, sub-agents, memory, context-window management) and agentic abstraction frameworks (e.g., Strands, LangGraph, PydanticAI) for building agents and workflows for multi-step tasks.

SUBy Solomon UdohReviewed by Solomon UdohAI-assisted · human-reviewed
In short
Agent memory patterns persist durable facts such as goals and decisions outside the live message list and re-inject them when needed. Tool-output pruning and compaction keep the working window focused as a task grows, and subagents provide memory isolation by holding a subtask's detail in a separate context. The aim is to retain critical facts across many steps without exhausting the context window.

Why long-running agents run out of room

An agent that works through many steps has a problem a single model call never faces: everything it does, every message and every tool result, competes for space in a finite context window. The Claude Certified Developer - Foundations (CCDV-F) exam treats managing that pressure as an apply-level skill. The goal is precise: retain the critical facts across many steps without exhausting the context window. Getting there means being deliberate about what stays in the live context, what gets stored elsewhere, and what gets condensed or removed.

The reason this is hard is that context is not free real estate you can keep filling. As a task grows, tool outputs accumulate, intermediate reasoning piles up, and the earliest content, which often includes the original goal and instructions, is the first at risk of being pushed out. An agent that loses its instructions midway through a task starts making decisions unmoored from what it was actually asked to do. Managing memory and the context window is how you prevent that.

Agent memory and context-window management
A set of patterns for retaining critical facts across many agent steps without exhausting the context window: persisting durable facts outside the live message list and re-injecting them, pruning and compacting tool output to keep the window focused, and isolating subtask detail in subagents.

Persist durable facts outside the message list

The first pattern is memory: persist durable facts such as goals and decisions outside the live message list, then re-inject them when they are needed. Rather than trusting that the original goal will still be in the window fifty tool calls later, you store it deliberately, in a scratchpad, a memory store, a file, and bring it back into context at the moments the agent needs to act on it. The durable facts are the things that must survive the whole task: the objective, the key decisions made along the way, the constraints that must not be violated.

This decouples what the agent must remember from what happens to be in the recent message history. The live message list churns as the task proceeds; the persisted memory does not. Re-injecting a compact statement of the goal and the decisions taken so far keeps the agent anchored even when the raw conversation that produced those decisions has long since scrolled out of the window.

Prune and compact to keep the window focused

The second pattern is keeping the working window lean through tool-output pruning and compaction. Tool calls are often the biggest source of context bloat: a search returns pages of results, a file read returns an entire document, and most of that is irrelevant a few steps later. Pruning removes tool output that is no longer needed, and compaction condenses the working context so it stays focused on what the current step actually requires. As the task grows, these two techniques are what stop the window from filling with stale detail.

There is a discipline to compaction, though, and it leads straight to one of the exam traps. Compaction is safe for detail that has served its purpose, but it is dangerous when applied to facts that must be preserved exactly. Some information is case-critical and must be kept verbatim, not summarised, because a paraphrase can drop the precise value that a later step depends on. The skill is separating the disposable and summarisable from the must-keep-exactly, and only compacting the former.

persist
durable facts kept outside the live message list
prune + compact
keep the working window focused
isolate
subagents hold subtask detail in a separate context

Isolate subtask detail with subagents

The third pattern is memory isolation through subagents. When a subtask generates a lot of detail, running it in a subagent keeps that detail in a separate context rather than dumping it into the main agent's window. This is the same subagent context isolation principle applied as a memory-management tool: the subagent gets the full context it needs to do its part, does the work, and returns only the distilled result, so the parent's window stays lean while the subtask still runs at full detail.

Isolation is powerful precisely because it prevents the accumulation problem at the source. Instead of the main context absorbing every intermediate output from a deep subtask, only the conclusion crosses back. The parent agent keeps its focus, and the heavy detail lives and dies inside the subagent's own context.

Three techniques for keeping an agent's context focused
Loading diagram...
Persistence, pruning and compaction, and subagent isolation together keep critical facts in reach without exhausting the window.

What the CCDV-F exam trips candidates on

The exam tests two traps here, and both are about mismanaging what occupies the window.

The first is letting raw tool output accumulate in context until critical early instructions fall out of the window. A scenario will show an agent that behaves well early, then drifts or forgets its original goal deep into a long task. The cause is unpruned tool output crowding out the instructions, and the fix is pruning and compaction plus persisting the goal so it can be re-injected. Recognising that the lost instructions are a context-management failure, not a model failure, is the point.

The second is summarising case-critical facts that must be preserved verbatim. A scenario will show compaction applied indiscriminately, condensing a fact that a later step needed exactly, and producing a wrong result because the precise value was lost in the summary. The credited answer keeps must-keep facts verbatim and only compacts the disposable detail. Both traps reward the same judgement: manage the window aggressively, but never at the expense of the facts the task actually depends on.

Worked example

A research agent is given a strict compliance rule and an exact account number at the start of a task, then runs dozens of tool calls gathering documents. By the end it violates the rule and cites the wrong account. What went wrong and how should it be redesigned?

Both failures trace to context management, not to the model being incapable. The dozens of tool calls returned large outputs that accumulated in the window, and as the task grew, the earliest content, the compliance rule and the exact account number, was pushed toward the edge of the window and effectively lost. The agent then acted without the instructions and the precise value it was originally given.

The redesign applies all three patterns. Persist the durable facts: store the compliance rule and the exact account number outside the live message list and re-inject them at each step where the agent is about to act, so they are always in context when they matter. Prune and compact the tool output: drop document text once it has been used and condense the running context so it stays focused, freeing the room the raw outputs were consuming. And isolate the detail-heavy gathering in a subagent, so the parent context receives only distilled findings rather than every page fetched.

One caution ties directly to the second trap. The account number must be preserved verbatim, never summarised, because it is a case-critical fact where any paraphrase could corrupt the value. So the compaction applies to the bulky document detail, while the account number and the compliance rule are persisted exactly and re-injected unchanged. That combination keeps the window focused and keeps the facts the task depends on both present and precise.

Common misreadings to avoid

Misconception

As long as the context window is large, an agent will remember its original instructions through a long task.

What's actually true

Raw tool output accumulates and can push early instructions out of the window regardless of its size. Durable facts must be persisted outside the live message list and re-injected, and tool output must be pruned and compacted to keep the window focused.

Misconception

Compaction is always safe because summarising context just saves space.

What's actually true

Some facts are case-critical and must be preserved verbatim. Summarising them can drop the exact value a later step depends on. Compact disposable detail, but keep must-keep facts exactly as given.

How this shows up on the exam

Domain 1 questions on this knowledge point describe an agent that loses track of something across a long task and ask you to diagnose and fix it. The reliable reading is that the loss is a context-management problem: persist the durable facts and re-inject them, prune and compact accumulating tool output, and isolate detail-heavy subtasks in subagents, all while keeping case-critical facts verbatim.

This knowledge point builds on subagent context isolation, which supplies the isolation technique, and it pairs naturally with custom agent loops and deterministic hooks, since a hand-built loop is exactly where you insert pruning and re-injection deliberately. It also feeds forward into the agentic abstraction frameworks that standardise state passing across steps. Managing memory and the window well is what lets a multi-step agent stay coherent from the first tool call to the last.

Check your understanding

An agent is given an exact policy number and a hard constraint up front, then runs many document-fetching tool calls. Late in the task it forgets the constraint and misquotes the policy number. Which redesign best addresses both problems?

People also ask

How does an agent keep facts without exhausting the context window?
Memory patterns persist durable facts such as goals and decisions outside the live message list and re-inject them when needed, so critical information survives even as older messages leave the window.
What is context compaction in an agent?
Compaction condenses the working context as a task grows, alongside pruning of accumulated tool output, so the window stays focused on what the current step needs rather than filling with stale detail.
How do subagents help with memory?
A subagent holds a subtask’s detail in its own separate context, so that detail never crowds the main agent’s window. The parent stays lean while the subtask still gets full context.

Watch and learn

Official Anthropic Academy lessons first, then hand-picked walkthroughs. Videos load only when you press play.

No videos curated for this concept yet

We are still curating the best official and community videos for this topic.

References & primary sources

Adaptive study

Master this concept with Archie

Practice it inside an adaptive study session. Archie, your Socratic AI tutor, tracks your mastery with Bayesian Knowledge Tracing and schedules the perfect next review.

Start studying