Notes Work in progress #ai-agents#memory#llm

AI Agent Memory: Short-Term, Persistent, and Long-Term

How agents remember things within a conversation, across sessions, and over time.

Written November 21, 2026

These are my notes from Google Cloud Tech’s AI Agent Crash Course on YouTube, with my own takeaways added along the way. Videos are listed under References at the end.

An LLM is stateless. Every call starts from zero, and the model only “knows” what is in the prompt you send it. So when we say an agent has memory, we mean the system around the model decides what to keep, where to store it, and what to put back into the prompt on the next turn.

I find it useful to think about agent memory in three layers.

1. Short-term memory

What it is: Everything the agent is holding right now, inside one conversation or one task run.

  • The conversation history (user messages, agent replies)
  • Tool calls and their results from earlier steps
  • A scratchpad or working state, like the current plan or intermediate results

Where it lives: In the context window, usually kept in memory by the application while the session is running.

The main constraint: The context window is finite. As a conversation grows, you have to decide what stays in the prompt. Common approaches:

  • Trimming: keep only the last N turns
  • Summarizing: compress older turns into a short summary
  • Selective inclusion: keep tool results only while they are still relevant
[ system prompt ]
[ summary of older turns ]
[ last few turns ]          ← short-term memory
[ current tool results ]
[ new user message ]

2. Persistent memory

What it is: The state of a session saved to durable storage, so the agent can pick up where it left off after a restart, a timeout, or the user coming back later.

  • Conversation history and session state saved to a database
  • Checkpoints of a long-running workflow (which step it reached, what it decided)
  • Per-session or per-user settings that should not be lost

Where it lives: A database or key-value store, keyed by session or user ID.

Why it matters: Without it, any crash or redeploy wipes the conversation. With it, long-running or human-in-the-loop workflows can pause for approval and resume safely.

The key difference from short-term memory is lifetime, not content: it is often the same data, written somewhere that survives the process.

3. Long-term memory

What it is: Knowledge the agent accumulates across many sessions and recalls when it is relevant, even in a brand-new conversation.

It is often split into three kinds:

Kind What it stores Example
Semantic Facts and preferences “The user prefers Python and concise answers.”
Episodic Past events and experiences “Last week we debugged a failing batch job together.”
Procedural How to do things Refined instructions or a playbook the agent has learned works well

Where it lives: Usually a vector store or a structured store. The agent (or a background process) extracts what is worth remembering, saves it, and later retrieves the relevant pieces into the prompt, similar to RAG.

Putting it together

Short-term Persistent Long-term
Scope One conversation or task One session, across restarts Across all sessions
Lifetime Until the session ends Until the session is closed or expires Weeks to forever
Storage Context window / app memory Database, checkpoints Vector or structured store
Gets into the prompt by Being there already Reloading the session Retrieval

Design questions I keep coming back to

  • What is worth remembering? Saving everything makes retrieval noisy.
  • When to write? During the conversation, or in a background step afterward?
  • How to forget? Old or wrong memories need to expire or be corrected.
  • Privacy and control: Users should be able to see and delete what an agent remembers about them.

References

  1. How to add short-term memory to your AI agent (Sessions & State Explained) ↗ · Google Cloud Tech · Video
  2. How to add persistent memory to your AI agent ↗ · Google Cloud Tech · Video
  3. AI agent long-term memory with memory bank ↗ · Google Cloud Tech · Video
  4. AI Agent Crash Course (full playlist) ↗ · Google Cloud Tech · Video