Memory types · Working memory

Short-Term Memory in AI Agents

Short-term memory in AI agents is the information held in the current task and recent turns — primarily inside the context window — before it is consolidated into long-term storage or discarded.

Short-term lifecycle

1
Accumulate
In context window
2
Use
Current reasoning
3
Promote
Or discard
4
Clear
Session ends

Definition

What is short-term (working) memory in agents?

Working memory is the active scratchpad for the current goal, recent messages and tool outputs — living in the context window plus small buffers.

It is volatile: cleared when the session ends unless promoted to long-term storage. Also called “context memory” in some frameworks — but that term often confuses working memory with persistent AI memory; see memory vs context window.

Types of AI agent memory

Not LSTM: “Long short-term memory” (LSTM) is a recurrent neural network architecture (Hochreiter & Schmidhuber, 1997) — not agent working memory. Agent short-term memory = the context window and buffers, not a neural net layer type. For the cognitive analogy, see AI memory vs human memory.

Mechanism

How short-term memory works in practice

Messages accumulate in the prompt; when the window fills, agents summarize, truncate or page out oldest turns.

Framework buffers include LangChain ConversationBuffer and LangGraph checkpoint state for recent turns. Tool results inject directly into working memory for the current reasoning step.

Memory vs context window

Constraints

Limits of short-term memory

Token caps, truncation of oldest turns, per-token cost and no cross-session persistence by default.

GPT-4: 128K tokens; Claude 3.7 Sonnet: 200K (as cited in Chhikara et al., 2025). When the limit hits: summarize, drop or promote to long-term memory.

The context window problem

Transition

Promoting short-term to long-term memory

Extraction → consolidation → external store.

Promote when a fact is durable (preferences, identity, recurring context); discard when ephemeral (greeting, one-off clarification).

Memory consolidation · Long-term memory

Comparison

Short-term vs long-term memory

DimensionShort-termLong-term
LocationContext windowExternal store
PersistenceSessionCross-session
CapacityModel token limitUnbounded (store)
CostPer token in windowPer embed + retrieve

Short-term vs long-term (full guide)

Patterns

Frameworks and patterns for working memory

Context window only; buffer + summarization; Letta paging tiers.

  • Context window only — simplest; no persistence across sessions
  • Buffer + summarization — LangChain buffers compress old turns
  • Letta paging — core memory in window, rest paged to deep store (MemGPT pattern)
  • External memory + window — Engram, Mem0 and Zep retrieve into the window each turn; working memory stays in-context

Virtual context & MemGPT · Letta alternatives

FAQ

Frequently asked questions

What is working memory in AI agents?

Working memory is the active information in the context window for the current task — recent messages, tool outputs and retrieved memories. It is volatile and session-bound. See definition above.

Is short-term memory the same as the context window?

Mostly yes for agents — the context window is the primary short-term/working memory tier, often plus small buffers. Persistent memory lives outside the window. See memory vs context window.

Should I use LSTM for agent memory?

No. LSTM is a neural network architecture for sequence modeling (Hochreiter & Schmidhuber, 1997), not agent working memory. Agents use context windows and external memory stores, not LSTM layers for conversation memory.

What does context memory mean?

Usually information in the context window (working memory), not persistent cross-session storage. For durable memory, use an external store. See memory vs context window.

What is role context memory?

Role context is the system prompt and persona in the window — instructions for how the agent behaves, not facts about users. User facts belong in external long-term memory.

How long does short-term memory last?

For the current session only — until the context window is cleared, the session ends or facts are promoted to long-term storage. No cross-session persistence by default.

When should I promote short-term to long-term memory?

When a fact is durable: preferences, identity, recurring context. Discard ephemeral turns (greetings, clarifications). See memory consolidation.

Does Claude have short-term memory?

Claude's API context window holds short-term/working memory per call. Cross-session persistence requires external memory (Engram, Mem0, Zep, etc.). See persist conversation memory.

How does n8n handle agent short-term memory?

n8n passes conversation history in the prompt (working memory). For persistence across sessions, wire Engram, Mem0 or Zep APIs. See add memory to an agent.

Buffer memory vs vector memory?

Buffer memory keeps recent turns in the prompt (short-term). Vector memory stores embeddings in an external index (long-term). Production agents use both. See long-term memory.