Working Memory (Agent)
Hold a phone number in your head while you walk across the room and you are using working memory — a small, deliberately temporary store for exactly what the task at hand needs. An agent needs the same thing, for the same reason: details that matter right now will not matter in ten minutes.
What it holds
Working memory is an agent's active scratchpad for the task in progress: the goal as currently understood, the plan and which step it is on, the last few observations, intermediate values, and notes it wrote to itself. Where short-term memory is simply the recent conversation and long-term memory is what survives between sessions, working memory is curated — written into on purpose and cleared when the task ends. In practice it occupies part of the context window, or a structured state object such as a LangGraph state or a scratchpad file that is re-injected on every turn.
Why the loop depends on it
It is the thread that ties one step to the next:
- Without it, step seven has no idea what step three found, and the agent re-calls a tool it already called.
- The plan lives here between turns, so a drifting or forgotten goal is usually a memory failure, not a reasoning failure.
- It is bounded, so something must decide what to keep — which is the job compaction and summarisation exist to do.
When it is misconfigured
Overfill it and task detail is pushed out by raw tool output — the classic long-run failure where an agent forgets what it was asked while still dutifully calling tools. Keep too little and it loses the thread between steps. Persist it past the task and yesterday's half-finished plan leaks into today's run.
Working memory is an agent's active scratchpad for the task in progress: the current goal, the plan and its position in it, recent observations and intermediate results. It is deliberately temporary, bounded by the context window, and curated rather than accumulated. It matters because it carries state between steps of the plan–act–observe loop — without it an agent repeats tool calls, loses its plan, and drifts away from the original request.
When you walk to the kitchen repeating a phone number under your breath, you are using working memory — a small mental notepad for whatever you are doing right now. You throw it away afterwards.
AI software that works through a task on its own needs the same notepad: what am I trying to do, what have I already tried, what did that last step tell me. It is small on purpose, because there is limited room, so the software has to keep what matters and drop the rest. When it gets that wrong you notice immediately — the task wanders off course, or the same step gets done twice.