AITraining2U

Programs

Resources

Case Studies

Quick Links

Enquire Now
Domain 5 · 15%% of exam

Context editing, compaction and memory

Three mechanisms, three different jobs. Expect a "which one" question.

4 min read · Lesson 4 of 9 in this domain

Three mechanisms manage long-running context and they are routinely confused, so anchor them by what they physically do. Context editing prunes: stale tool results are removed and not replaced. Compaction summarises: earlier turns are condensed into a summary block so the conversation can continue past the window. Memory persists: files written to a memory directory outlive the session entirely. The first two operate within one session; only memory crosses sessions. A scenario asking about state surviving a restart has exactly one answer.

Key points
  • Context editingprunes. Clears stale tool results and thinking blocks. The content is removed, not summarised.
  • Compactionsummarises. When a conversation approaches the window limit, earlier context is condensed server-side.
  • Memorypersists. State survives across separate sessions via files in a memory directory.
  • Critical compaction implementation detail: append the full response.content back to your message history. The compaction blocks must be preserved — extracting only the text silently loses the compaction state.
  • Editing and compaction operate within a session; memory is across sessions. Many long-running agents use all three.
  • None of these is max_tokens, which is only a per-response output cap.
Diagram
Prune, summarise, or persist
Context editingPRUNESremoves stale toolresults outrightwithin a sessionCompactionSUMMARISEScondenses earlierturns to fitwithin a sessionMemoryPERSISTSfiles that outlivethe sessionACROSS sessions
Reference
Need Mechanism
Remove stale tool resultsContext editing (prunes)
Conversation will exceed the windowCompaction (summarises)
State must survive across sessionsMemory (persists)
Cap one response lengthmax_tokens
Exam trap

Compaction and context editing are offered interchangeably. One summarises, one deletes.

Check your understanding

Stale tool results are cluttering a long session. Which mechanism removes them?

Correct answer: B — Context editing
Context editing prunes; compaction summarises.

State must survive across separate sessions. Which mechanism?

Correct answer: C — Memory
The first two operate within one session only.

Practise this domain with 15%%-weighted questions in the study app.

Open in study app

Source: Claude Docs — Context editing · Independent study aid, not affiliated with or endorsed by Anthropic.