Claude Context Management: Summaries, Subagents, Trimming
What to keep and what to trim in long Claude sessions: case-facts blocks, lost-in-the-middle fixes, subagent handoffs and scratchpad files.
A long session rarely fails with an error. It fails quietly: the refund amount turns into "a partial refund", a finding from page 40 of a report goes missing, or an agent that read your codebase an hour ago starts talking about "typical patterns" instead of the classes it actually found. This post covers the Claude context management habits that prevent that drift, and how Domain 5 of the CCAR-F exam tests them.
Why long context degrades
A big context window isn't free storage. Task Statements 5.1 and 5.4 name three effects.
- Lossy summarization. When you compress history to save tokens, the first things to blur are numbers, dates, percentages and what the customer said they expect. "Customer wants $142.50 back for order #8812 by Friday" becomes "customer wants a refund".
- Lost in the middle. Models handle the start and end of a long input reliably and are more likely to miss what sits in the middle.
- Tool-result bloat. An order lookup that returns 40 fields, when you need 5, eats context out of proportion to its value.
Long exploration sessions add a fourth symptom: answers turn generic because the specific discoveries have scrolled away or been compacted.
What to keep and what to trim
A useful rule: keep anything a later step would need to act on or defend. Trim anything that only explains how you got there.
| Keep (verbatim, structured) | Trim or drop |
|---|---|
| Goal of the task and success criteria | Pleasantries and repeated restatements |
| Hard constraints (policy limits, deadlines, "don't touch module X") | Raw tool output fields nobody uses |
| Decisions already made, with the reason | Full reasoning chains from subagents |
| Open items and unanswered questions | Search results that turned out irrelevant |
| Evidence: amounts, IDs, dates, file paths, source URLs | Duplicate copies of the same document |
The "keep" column should not live inside the summarized history, where it gets blurred again on each compaction. Pull it into a separate case facts block that you include in every prompt. For a support agent juggling several issues, that's a small list per issue: order ID, amount, status, what was promised. The narrative can then be summarized freely.
For tool results, trim before they reach the context. If the refund flow only needs order_id, total, purchase_date, return_window_ends and status, filter the response down to those fields in your tool code.
When you aggregate many inputs, put a short key-findings summary at the top and organize the details under explicit section headers. That works with the position effect rather than against it.
Subagents that return condensed results
Exploration is the noisiest work an agent does. Task Statement 5.4's fix: delegate that work to a subagent with a narrow question ("find all test files that touch refunds", "trace what calls issueRefund") and let the coordinator keep only the answer.
flowchart LR
C[Coordinator: goal, decisions, open items] -->|narrow question| S1[Subagent: explore tests]
C -->|narrow question| S2[Subagent: trace refund flow]
S1 -->|key facts + file paths| C
S2 -->|key facts + file paths| C
C --> P[(progress.md scratchpad)]
What the subagent returns matters as much as the delegation. Ask for structured output: key facts, file paths or source locations, dates, and a relevance note. Not its reasoning transcript, which is exactly what pushes important parts into the middle of a downstream agent's context. For research-style work, require claim-to-source mappings so attribution survives the handoff (that's Task Statement 5.6).
Between phases, summarize what the last phase learned and inject that summary into the next subagents' initial context.
Scratchpad and progress files
Sessions crash, /compact runs, a new agent picks up the task tomorrow. A scratchpad file such as progress.md or findings.md keeps the key findings outside the window, so the agent can re-read them when a later question depends on earlier work.
Keep it short and factual:
## Goal
Add partial refunds to checkout without changing the payments adapter.
## Decisions
- Refund logic lives in RefundService (not OrderController): it already owns ledger writes.
## Open items
- Does PayoutJob assume full refunds only? Not checked yet.
## Evidence
- src/billing/RefundService.ts:88 issues the ledger reversal
For multi-agent pipelines, the same idea scales into structured state exports: each agent writes its state to a known location, and on resume the coordinator loads a manifest and injects it into agent prompts.
Try it
A coordinator agent reviews a 200-file service. After 90 minutes it begins describing "the usual repository pattern" for data access, though earlier it had identified a custom LedgerGateway class. The team wants consistent answers through the rest of the session. What should they do?
- A. Increase the model's max output tokens so it can write longer answers
- B. Have the agent record key findings in a scratchpad file and delegate further exploration to subagents that return condensed results
- C. Restart the session and paste the entire previous transcript as the first message
- D. Add "be specific and do not generalize" to the system prompt
Answer: B. The symptom is context degradation, and the fix is to persist findings outside the window and keep verbose exploration out of the coordinator's context. A doesn't touch the input side. C reloads the same bloated history, with the key discovery now sitting in the middle. D is a vague instruction that doesn't change what the model can see.
Key takeaways
- Pull transactional facts (amounts, IDs, dates, promises) into a persistent case-facts block outside summarized history.
- Trim tool outputs to the fields you need before they enter context.
- Put key findings first and use clear section headers when you combine long inputs.
- Delegate exploration to subagents and have them return structured facts with sources, not reasoning chains.
- Use scratchpad files and state manifests so findings survive compaction and crashes.
Frequently asked questions
Models reliably use information at the beginning and end of a long input but may overlook details in the middle. Put summaries up front and give sections clear headers.
Pass the history the conversation needs to stay coherent, since the API is stateless and only sees what you send. When you do summarize, keep exact facts in a separate structured block so compression can't blur them.
When a task produces a lot of output you won't need later, such as searching a codebase or reading many sources. The subagent absorbs the noise and returns only the answer.
Context management connects closely to designing the agent loop and getting structured output from Claude, and the cheat sheet has the Domain 5 rules on one page. Practice Domain 5 scenarios to see how these ideas show up in exam questions.