When to reach for it
- Multi-step tasks require tracking intermediate states.
- Tool results will be referenced later.
- Reasoning must be traceable separately from execution.
/pattern/working-memory/
A temporary working state holds intermediate steps, variables, and open tasks during a single execution run.
In practiceA code-review agent writes intermediate findings — duplicate logic found, security issue noted — to a scratchpad state field, then collates all findings into a final report at the last step.
When to reach for it
When it backfires
The tradeoff
Better control during a single run is gained against the need for additional state management logic.
A short-lived scratchpad held across the steps of one task.
The model treats its own thinking notes as part of the response and emits the chain-of-thought to the user.
Fix · Hold scratchpad in a typed state field separate from the message channel. Render only the explicit final-answer field downstream.
Two fan-out branches write the same scratchpad key in one super-step. Last-writer-wins silently discards one branch's result and the run continues on half the data.
Fix · Give concurrent branches an append/reduce channel or per-branch namespaces, never a plain overwritten field; merge deterministically when they join.
Keep going
Search patterns, frameworks, and pages.