Explainer2 min read

Agent Memory Explained: Short-Term, Long-Term, Files

Language models are stateless: each call starts from nothing. Everything an agent "remembers" is something your system chose to put back in front of it.

TrueCodeAI Engineering
Agents, Voice & ML practice
Published
AI agentsMemoryExplainer
Person writing notes on paper beside a coffee cup

Four kinds of memory

Agent memory types
TypeWhat it holdsLifetime
Context windowThe current conversation and working dataOne session
SummariesCompressed history of long conversationsSession or across sessions
Long-term storeFacts and preferences about a user or accountPersistent
Files / scratchpadNotes, plans and intermediate results the agent writesTask or project

Design choices

  • Summarise long conversations instead of re-sending everything — it is cheaper and often more accurate.
  • Store facts as structured records (preferred language, account tier) rather than free text where you can.
  • Let long-running agents write plans and progress to files, so work survives restarts.
  • Retrieve memories by relevance, not all at once.

Privacy rules

  1. Tell users what is remembered and let them delete it.
  2. Never store secrets or payment data in agent memory.
  3. Scope memory per user or account — never share across customers.
  4. Set retention periods and enforce them.

Frequently asked questions

Does the model learn from conversations?

Not by itself. Memory is data your system stores and re-supplies; the model weights do not change.

Why does my agent forget in long chats?

The context fills up or older turns get truncated. Summaries and structured memory fix it.

Is long-term memory always useful?

Not always. For one-off support queries it adds little; for account managers and assistants it adds a lot.

Tell us what you want to exist.

We reply within 24 hours at hello@truecodeai.com with how we would build it.

Get a fixed price WhatsApp