An agent that keeps its working notes only in the conversation will lose them the moment the conversation is summarized or the run restarts. A scratchpad file is a small, plain-text file the agent reads at the start of each step and updates as it works: the goal, what is done, what is still open, and the facts found so far. LangGraph’s state works the same way at the framework level, with shared state passed between nodes, but a file has one advantage: a person can open it and see exactly where the run stands. Keep it short, keep it in one place, and make every step read it before acting.
What you need
- A multi-step agent task where steps depend on earlier findings
- A scratchpad file the agent can read and write, in a folder it may use
- A fixed scratchpad shape: goal, done, open, facts
Step 1: Fix the scratchpad shape before the run
Decide the four headings and their length limits: goal in one sentence, done as bullets, open as bullets, facts as bullets. No other sections, so the file stays short.
Step 2: Make each step read the file, then update it
At the start of each step the agent reads the scratchpad, and at the end of the step it writes back what changed. A step that does not update the file leaves the next step working from stale notes.
Step 3: Open the file yourself and check it matches the run
After a test run, open the scratchpad and compare it with the run log. If a step’s work is missing from the file, the update step is not wired in.
Worked example: synthetic scratchpad check
The table below is a synthetic example. It shows the expected result of the scratchpad; no agent was run.
| Section | Present? | Matches the run? |
|---|---|---|
| Goal | Yes | Yes |
| Done steps | Yes | Yes |
| Open items | Yes | Yes |
| Facts found | Yes | Yes |
Expected result (UNTESTED). the scratchpad has all four sections, each matching the run log, and every step reads it before acting. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- A scratchpad is a snapshot: facts found earlier can change before the next step acts.
- If two agents write the same file, the last writer wins, so give each run its own file.
- A file the agent never reads is decoration; check the read happens, not just the write.
- Keep the file short, or reading it costs as much context as the history it replaces.
