Module 7 · Agent Memory & State · Lesson 15 of 34

Short-term and long-term memory

Full history, sliding windows, summaries and memory stores: what each remembers and what it costs.

In this lesson · about 20 minutes

  • Tell short-term (context) memory from long-term (stored) memory
  • Compare four memory strategies on recall and cost
  • Decide what is worth saving as a long-term memory

The model remembers nothing between calls (Module 2). Everything an agent "knows" about the past is something your system chose to send. There are two layers:

  • Short-term memory: what is in the context window right now: recent messages, the current task, tool results.
  • Long-term memory: facts saved outside the model (in a database) and brought back when relevant: the user's preferences, past decisions, lessons learned.

Four common strategies:

  • Full history: send everything. Perfect recall until it no longer fits, and cost grows every turn.
  • Sliding window: send only the last N turns. Cheap and simple, but older facts vanish.
  • Running summary: compress older turns into a summary. Keeps the gist; small details can be lost.
  • Memory store: extract important facts as they appear, save them, and retrieve the relevant ones each turn. Best recall at low cost, but more moving parts, and a wrong memory can stick around.

Try it · simulator

Agent memory strategies

A customer chats about a birthday cake over 12 turns. Pick a memory strategy and see what the agent still knows at the end, and what each turn costs.

  1. #1Hi! I'm ordering a cake for my daughter's birthday party.fact
  2. #2Important: she is allergic to nuts.fact
  3. #3What flavours do you have?
  4. #4Her name is Lily, please write it on top.fact
  5. #5Chocolate sounds good. Do you do sprinkles?
  6. #6I'd like to keep it under $40.fact
  7. #7How long do cakes stay fresh?
  8. #8Can it be pink and purple?
  9. #9The party is on Saturday afternoon.fact
  10. #10Do you deliver to Riverside?
  11. #11Great. Will candles be included?
  12. #12OK, please confirm the full order.

Pink border: sent word for word. Green: carried as a summary or saved memory. Grey: forgotten.

Questions answered right

1 / 4

Context at turn 12

530tokens

At turn 200 it would be

530tokens

Moving parts

Few

Can the cake contain almonds? Says almonds are fine. Dangerous.
What name goes on top? Leaves the name blank or guesses.
What is the price limit? Suggests a $65 cake.
Which day is delivery? Saturday.
058811751763235018162330TurnTokens sent each turn

Check your understanding0 of 3 correct

Question 1

1.A sliding window of 4 turns. A key fact was given in turn 2 of 12. What happens?

Question 2

2.Which strategy's cost per turn keeps growing for the whole conversation?

Question 3

3.What is a risk of long-term memory stores?

Quiz score: 0 of 3

Tip: answer every quiz question correctly first.

Written by Noviq Academy in its own words. The simulators are small teaching models that keep the real idea and leave out the scale; their numbers (prices, speeds, scores) are illustrative. Model names, prices and features change quickly, so check your provider's current documentation before you build. Read-aloud uses your device's built-in voices.