A model doing something long has intermediate work: partial findings, a list of files still to check, an evolving theory of a bug. That work has to live somewhere. By default it lives in the conversation, where it competes with everything else for space and gets summarised away at the worst moment.
A scratchpad gives it somewhere else to live.
Two forms, different jobs
In-context, as a section of the response the model is told to use for working before answering. Cheap, needs no tooling, and disappears with the session:
Use a <scratchpad> section to work through this before answering.
Only the text after </scratchpad> is shown to the user.On disk, as a file the model appends to and re-reads. Survives compaction and the session ending, and is inspectable by you. This is the form that matters for long tasks:
## Investigating: intermittent 500s on /checkout
Checked
- app logs: no stack traces at failure times
- db slow query log: nothing above 200ms
Current theory
- upstream timeout, not our code. Next: check the payment gateway's status page.Why it helps beyond tidiness
- Findings stop being lost. Without a scratchpad, "already checked the db logs" lives only in history, and after a compaction the agent checks them again.
- The theory becomes correctable. You can read the current theory and say "no, it started after Tuesday's deploy" rather than watching it pursue a dead end.
- It separates working from output. The answer stops carrying the reasoning debris that made it.
Keeping it useful
- Append, then prune. A scratchpad that only grows becomes the thing it was meant to prevent.
- Record conclusions, not keystrokes. "db logs clean" beats pasting the log.
- Say explicitly when to read it back. A file the model writes and never re-reads is a diary, not memory.
notes.md the agent is told to append findings to and re-read before deciding what to do next. That one instruction removes most of the repeated-work problem in long debugging sessions.Related terms
Externalized state
Externalized state keeps the durable facts of a task in files rather than in the conversation, so the window holds pointers instead of being the record. It is what makes a long task survive a context that cannot.
Read definition →PatternValidatedCheckpoint
A checkpoint is a deliberate save point holding enough state to resume a task from there. It turns a long run from something that either finishes or is lost into something that can be picked up.
Read definition →ConceptConversation history
Conversation history is the running list of past turns you re-send on every request so the model appears to remember. It is the simplest form of memory, and the first thing to overflow a context window if you never prune it.
Read definition →AntipatternProvenContext rot
Context rot is the gradual decay of a long session as stale, superseded, and irrelevant text accumulates in the window. Nothing breaks at any single step, which is why it is usually diagnosed as the model getting worse.
Read definition →