What you need to know
The symptom of degradation
Hours into an exploration, answers become vague. Asked about the UserAuth class found two hours earlier, the agent describes "typical authentication patterns" instead of the specific methods it read. That is context degradation: the details are buried under thousands of lines of later tool output.
Five remedies
| Remedy | What it does |
|---|---|
| Scratchpad file | The agent writes key findings (class names, method signatures, decisions) to a file such as NOTES.md, and consults it for later questions. The file outlives context limits |
| Subagents for specific questions | "Find all test files" or "trace the refund flow's dependencies" goes to a subagent; only its summary returns, and the main agent keeps the high-level picture |
| Summaries between phases | Before spawning the next phase's subagents, summarise what the last phase found and inject that summary into their starting context |
| /compact | Compresses the conversation so far when context is full of verbose discovery output, so the session can continue |
| State exports | Each agent writes its state to a known location; on restart, the coordinator loads a manifest and injects the relevant state into each agent's prompt |
Crash recovery
Without exported state, a crash mid-investigation loses everything. A simple manifest is enough:
{"investigation": "booking-to-invoice",
"completed": [{"task": "map booking service", "notes": "notes/booking.md"}],
"in_progress": [{"task": "trace invoice creation", "agent": "explorer-2"}],
"pending": ["check rounding in currency module"]}
On resume, the coordinator reads the manifest, gives finished findings to the next phase and restarts only the unfinished tasks.
In the exam
Scenarios 2 and 4: vague answers late in a session, context filling with discovery output, a multi-phase investigation, or a crash that loses progress.
Check your understanding
After two hours, the agent describes "typical patterns" instead of the classes it found earlier. Which TWO help most? Select TWO.
Show answer
Answer: A, C. A scratchpad keeps findings outside the context; subagents keep verbose exploration out of the main context.
A multi-hour investigation loses everything when the process crashes. What design prevents this?
Show answer
Answer: B. Structured state written to a known location lets the coordinator resume from what was finished instead of starting again.
Context is full of verbose Grep output, but the session's conclusions are still needed. What command helps?
Show answer
Answer: C. /compact reduces context use while keeping a summary of the session, so work continues. /clear would discard it.
Apply it: Lakeshore's long investigations
Lakeshore's agent gets vague after hours and loses everything on a crash. Design its context strategy for "How does a booking become an invoice?"
- Define the scratchpad: file name, sections and when the agent writes to it.
- Name two questions to delegate to subagents and what each returns.
- Write the manifest for a run that crashed during phase 2.
- Say when to use /compact.
Show model answer
1. Scratchpad. notes/booking-to-invoice.md with sections: Entry points, Classes and key methods (with signatures), Data flow, Decisions, Open questions. The agent writes after each file that changes its understanding, and reads it before answering any question about earlier findings.
2. Delegated questions
- "List every class that creates or modifies an Invoice": returns class names, files and the method involved.
- "Trace the currency conversion used during invoicing": returns the call chain and the rounding rule.
3. Manifest. Phase 1 (map booking service) completed, notes in notes/booking.md; phase 2 task "trace invoice creation" in progress, partial notes in notes/invoice-partial.md; phase 3 "check rounding" pending. On resume, phase 2 restarts with the partial notes injected.
4. /compact. When the session has accumulated long Grep and file output and the scratchpad is up to date, run /compact before starting the next phase.