Skip to content
Claude Certified Architect – Professional (CCAR-P) Exam Prep

Lesson 10 of 31 · 6 min

x
10/31

Context Window Management

Video lesson: CCAR-P 10/31: Context Window Management

Mechanics (window contents, overflow behaviour, compaction and context editing, memory tool) are in context preservation. This note is the architecture decision.

Budget the window (verified facts, design use)

  • Everything counts: system prompt, messages including tool results, documents, images, tool definitions and the model's output including thinking.
  • Windows are 1M tokens on the current model families; maximum output is 128K tokens. Long-context requests are billed at standard pricing except Haiku 5.5 above 100,000 tokens (verified).
  • Context rot: accuracy and recall degrade as tokens grow, so a bigger window is not a licence to include everything.

Where information should live

InformationBest placement
Stable rules, tool definitions, referenceSystem prompt or cached prefix (D2.2)
Large corpus, queried selectivelyRetrieval or tools, loaded just in time (D3.6)
Facts that must survive resetsMemory tool or state files (client-side)
Old tool output no longer neededCleared by context editing
Very long dialogueCompaction (summary)
Exploration noiseA subagent's own context

Choosing a long-context strategy

SituationChoice
Conversation grows past the windowCompaction (on demand or at a token threshold; beta)
Agent loop accumulates tool resultsContext editing (clear old tool results; configurable trigger and keep)
Work spans sessionsMemory tool plus progress files; start fresh sessions by reading state
Many tools bloat the promptTool search with deferred loading (D3.5)
Heavy explorationSubagents

Compaction keeps active context small; memory preserves what must survive summarisation (verified guidance).

Placement inside a prompt

Long documents at the top, query at the end; wrap documents in <document> tags with source metadata.

Cost and latency implications

More tokens cost more and slow responses; cached prefixes reduce price but still occupy the window; clearing content invalidates the cache, so clear enough tokens to justify the rewrite. Use the token counting API to estimate requests.

Exam traps

  • "1M tokens, so include everything."
  • Relying on a summary to carry exact identifiers with no persistent facts.
  • Context editing that thrashes the cache (small, frequent clears).
  • Treating the memory tool as hosted storage. It is client-side.

References

  1. Context windows — checked Oct 16, 2026
  2. Compaction — checked Oct 16, 2026
  3. Memory tool — checked Oct 16, 2026

Check your understanding

  • A 400-turn support session nears the window. Options?Show answer

    Answer

    Compaction for the dialogue, memory for durable facts, context editing for old tool results.
  • Why does clearing tool results need clear_at_least?Show answer

    Answer

    Clearing invalidates the cached prefix; clear enough to pay for rewriting it.
  • Where does the memory tool store data?Show answer

    Answer

    In your application's storage; Claude only requests operations.
Previous

Progress is saved in this browser.

Next Lesson