CCDV-F · Domain 6: Prompt and Context Engineering · 15% of the exam
Task 6.1: Context Management for Long-Running Sessions
Spotting context bloat or drift in a long session or agent and choosing the remedy: compaction, pruning old tool output, isolating work in subagents, or rules for starting over in a fresh session.
Study it
Long sessions: compaction, pruning tool output, subagents and fresh starts
Try each one before opening the answer. Every option is explained, with the Anthropic documentation page that proves it.
Question 1 · choose 1
Early in a long Claude Code session, Claude read docs/billing-spec.md, a 12,000-token specification, along with several source files. After the session compacts, the context shows:Read src/billing/invoice.ts
Read src/billing/tax.ts
Referenced file docs/billing-spec.mdClaude's next answers ignore details of the specification. What explains this, and what should you do?
AIt exceeds the re-read size limit, so only its path came back; have Claude reread what it needs
BCompaction drops every file Claude read; ask Claude to read all the files again
CThe specification was edited after it was read, so compaction marked it stale; restore it from Git
DReferenced files are reloaded only by a SessionStart hook; add one that prints the specification
Show the answer and why
AIt exceeds the re-read size limit, so only its path came back; have Claude reread what it needs
Correct
A file over 5,000 tokens comes back as a path reference without its content, shown as Referenced file.
BCompaction drops every file Claude read; ask Claude to read all the files again
Incorrect
Claude Code re-reads up to five recently modified files after compaction; the two source files came back.
CThe specification was edited after it was read, so compaction marked it stale; restore it from Git
Incorrect
Referenced file marks a large file brought back by path, not a stale one.
DReferenced files are reloaded only by a SessionStart hook; add one that prints the specification
Incorrect
Claude Code re-reads recent files itself; this file came back as a path because of its size.
Right after compaction, Claude Code re-reads up to five of the files Claude read or edited, most recently modified first. A file over 5,000 tokens comes back as a path reference without its content, shown as Referenced file, so Claude needs to read the parts it needs again.
Your own agent harness compacts long sessions by asking Claude to summarize the conversation when the window nears its limit. After compaction the agent keeps losing small details that turn out to matter hours later, such as a config flag it had ruled out. According to Anthropic's guidance on context engineering, how should you improve the compaction prompt?
AMake the summary as short as possible so that the new context window has the most free space for new work
BTune it on complex agent traces, maximizing recall first so nothing is lost, then improving precision
CCompact much earlier, after every few turns, so that each summary covers less history
DSkip compaction and wait for a model with a larger context window to remove the problem
Show the answer and why
AMake the summary as short as possible so that the new context window has the most free space for new work
Incorrect
Aggressive compaction is what loses subtle but critical context.
BTune it on complex agent traces, maximizing recall first so nothing is lost, then improving precision
Correct
Overly aggressive compaction loses subtle context; the guidance starts with recall, then trims superfluous content.
CCompact much earlier, after every few turns, so that each summary covers less history
Incorrect
More frequent summaries still drop details unless the prompt keeps them.
DSkip compaction and wait for a model with a larger context window to remove the problem
Incorrect
Context windows of all sizes remain subject to context pollution and relevance concerns.
Compaction summarizes a conversation near the window limit and continues from the summary. The art lies in what to keep: overly aggressive compaction loses subtle context, so tune the prompt on complex agent traces, maximizing recall first and then improving precision.
You finished an OAuth migration in a long Claude Code session and now want to fix an unrelated CSS bug. The migration context is no longer needed for the new task, but you may want to revisit that session next week. What does Claude Code's guidance recommend?
AKeep working in the same session, since the cache makes old history free to send
BRun /compact so that the migration history shrinks to a summary before the CSS work starts
CRun /branch so that the CSS work continues from a copy of the current conversation
DRun /clear oauth-migration, which starts fresh and names the session you leave so you can return to it
Show the answer and why
AKeep working in the same session, since the cache makes old history free to send
Incorrect
Every request still sends the whole conversation; the cache discounts it but does not make it free.
BRun /compact so that the migration history shrinks to a summary before the CSS work starts
Incorrect
A summary of the migration still rides along with every turn of the unrelated task.
CRun /branch so that the CSS work continues from a copy of the current conversation
Incorrect
A branch carries the whole migration conversation into the new task.
DRun /clear oauth-migration, which starts fresh and names the session you leave so you can return to it
Correct
/clear between unrelated tasks stops the next task from paying for the previous one's history.
Every request sends the whole conversation, so a session carrying an earlier, unrelated task keeps paying for it. Run /clear between unrelated tasks; passing a name labels the session you are leaving so that you can come back to it later.
In Claude Code, Claude reads a 90,000-token generated log in several pieces instead of in one Read call. A developer asks why one call doesn't return the whole file. What does the tools reference say?
ARead accepts only files under 1,000 lines, so longer files must be split on disk first
BRead returns only the first part of any file, and the rest cannot be read in the session
CRead streams the whole file, and the pieces are only how the terminal displays it
DOne Read call returns at most 25,000 tokens by default, so Claude reads a larger file in pages
Show the answer and why
ARead accepts only files under 1,000 lines, so longer files must be split on disk first
Incorrect
The limit is on how much one call returns; Claude pages through larger files itself.
BRead returns only the first part of any file, and the rest cannot be read in the session
Incorrect
Claude reads larger files in pages with offset and limit.
CRead streams the whole file, and the pieces are only how the terminal displays it
Incorrect
A single Read call returns a bounded amount of the file.
DOne Read call returns at most 25,000 tokens by default, so Claude reads a larger file in pages
Correct
The default can be changed with CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS.
By default one Read call returns at most 25,000 tokens, or the value set in CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS, so Claude reads a larger text file in pages with offset and limit.
A developer hesitates to start a fresh Claude Code session for a new task because they fear losing the project's conventions written in the repository's CLAUDE.md. What does the memory documentation say?
AThe conventions are lost until the developer runs /init again in the new session
BThe conventions carry over only if the old session is resumed
CCLAUDE.md is loaded at the start of every conversation, so a fresh session has the conventions again
DThe conventions load only after Claude edits a file in the project
Show the answer and why
AThe conventions are lost until the developer runs /init again in the new session
Incorrect
/init drafts a CLAUDE.md; an existing one loads by itself.
BThe conventions carry over only if the old session is resumed
Incorrect
CLAUDE.md is not part of a session's history; it loads in every new session.
CCLAUDE.md is loaded at the start of every conversation, so a fresh session has the conventions again
Correct
Memory files load at the start of every conversation.
DThe conventions load only after Claude edits a file in the project
Incorrect
A project-root CLAUDE.md loads at launch, not on demand.
Claude Code's memory files, including CLAUDE.md, are loaded at the start of every conversation. Starting a fresh session drops the old conversation, not the project's written conventions.