Skip to content
AgenticAIWiki
  1. Learn
  2. Part 10
  3. 57. Managing memory over time
  4. 57.1

Lesson 57.1 · 1 of 5 · 4 min read · Reviewed 24 Nov 2026

Deciding what to remember

By the end, you can

  • Decide what an agent should remember.
  • Write memories that will be useful later.

A test for each candidate memory

  1. Durable? Will it still be true next month?
  2. Specific? Is it concrete enough to act on?
  3. Useful? Will a future session behave better knowing it?
  4. Appropriate? Would the user expect and accept you remembering it?

Usually worth storing

  • Stated preferences: “keep answers short”, “use metric units”
  • Decisions: “we chose Postgres over MongoDB for the events service”
  • Recurring issues: “printer driver fails after updates”
  • Lessons from failure: “retrying the flaky test hides the real bug”

Usually not

  • Small talk and one-off moods
  • Anything already in a system of record
  • Secrets, passwords and keys (never)
  • Sensitive personal dataPII: Personally identifiable information: data that can identify a person, such as name, email, address or ID numbers. unless clearly needed and agreed

Who decides

Approach Notes
Agent decides, with a rubric in the prompt Flexible; review samples
Explicit: “remember that…” Clear consent; misses implicit preferences
Hybrid: agent proposes, user confirms Good for sensitive products

Transparency

Let users see what’s remembered and delete it. A “what do you remember about me?” answer should match the store exactly.

Key points

  • Not everything is worth remembering: store what is durable, specific and likely to matter again.
  • Good memories: stated preferences, decisions, recurring problems, and lessons from failures.
  • Ask the user before storing sensitive facts, and let them see and delete what's stored.
Hands-on labRuns in the Playground

Score candidate memories before saving

Apply the durable, specific, useful and appropriate test to candidate memories and decide store, ask the user, or reject.

You will have: A decide function and a printed decision with a reason for each of eight candidates.

Steps

  1. Read the CANDIDATES list in the starter.
  2. Reject secrets, small talk and facts a system of record owns, with a reason.
  3. Send sensitive personal data (health, religion and similar) to 'ask user' instead of storing silently.
  4. Store durable preferences, decisions, recurring issues and lessons.
  5. Print each candidate, the decision and the reason, then the totals.

Done when

  • The password and the account balance are rejected.
  • The health detail goes to 'ask user'.
  • At least three candidates are stored.

Open in the Playground No API key needed.

Starter code (Python)
import re
CANDIDATES = [
    "Prefers email updates, not phone calls",
    "Said hello at the start",
    "We chose Postgres over MongoDB for the events service",
    "Their password is in the notes app",
    "Current account balance is 120 credits",
    "Mentioned they are being treated for asthma",
    "Retrying the flaky test hides the real bug",
    "Was in a hurry today",
]

def decide(text):
    t = text.lower()
    # TODO: return (decision, reason) where decision is "store", "ask user" or "reject"
    return ("store", "not checked yet")

for c in CANDIDATES:
    d, why = decide(c)
    print("%-58s %-9s %s" % (c, d, why))
Show a solution
import re
CANDIDATES = [
    "Prefers email updates, not phone calls",
    "Said hello at the start",
    "We chose Postgres over MongoDB for the events service",
    "Their password is in the notes app",
    "Current account balance is 120 credits",
    "Mentioned they are being treated for asthma",
    "Retrying the flaky test hides the real bug",
    "Was in a hurry today",
]
SECRET = re.compile(r"password|passcode|api key|pin\b")
RECORD = re.compile(r"balance|current plan|order status")
SENSITIVE = re.compile(r"treated for|diagnos|religio|pregnan")
TRANSIENT = re.compile(r"hello|today|in a hurry|thanks")
DURABLE = re.compile(r"prefer|chose|decid|always|hides|fails|bug")

def decide(text):
    t = text.lower()
    if SECRET.search(t):
        return ("reject", "never store secrets")
    if RECORD.search(t):
        return ("reject", "a system of record owns it; look it up")
    if SENSITIVE.search(t):
        return ("ask user", "sensitive: needs clear consent")
    if TRANSIENT.search(t):
        return ("reject", "not durable")
    if DURABLE.search(t):
        return ("store", "durable, specific and useful")
    return ("reject", "not specific enough")

totals = {}
for c in CANDIDATES:
    d, why = decide(c)
    totals[d] = totals.get(d, 0) + 1
    print("%-58s %-9s %s" % (c, d, why))
print("totals:", totals)
Quick checkWhich is the best thing for a support agent to save as long-term memory?
How sure are you?
Pick an answer and how sure you are