Skip to content

Interview question · Agent Memory & State

Design memory for an assistant that works with the same customer for six months.

The storage is the easy part. The design is the policies: what earns a write, what each record carries, what is read into which request, how a wrong memory is corrected, and how you prove memory is helping.

hardEssentialNewUpdated Nov 2026

TL;DR: Keep three kinds of memory for the customer: stated facts and preferences (keyed, with source and expiry), project context (open issues, decisions and why, until closed), and episodes (a compact record of each session, read as examples). The model proposes writes; the harness scopes them to the customer from the session, screens out secrets and sensitive inferences, and records the basis. Each request gets a small, prioritised slice, with age and source shown. Corrections supersede, the customer can see and delete what is kept, and an A/B comparison shows whether memory helps.

How to approach it

Clarify the product: a support or account assistant, who the customer is (one person or a company with several contacts), what consequential actions the assistant can take, and what the customer has agreed to be remembered. Then design the write path, the record, the read path, correction and deletion, and measurement, in that order.

A strong answer

Scope. The customer is a company with several contacts. Memories are scoped to the company account, with some scoped to a contact ("Priya prefers calls") and visible only in that contact's sessions. Scope comes from the authenticated session, never from the model.

What is kept.

KindExampleLifetime
Stated preferences"Send summaries on Fridays"; "escalate outages to the ops alias"Until changed; reconfirm yearly
Account facts not owned elsewhere"Pilot covers the Pune warehouse only"Until the pilot ends
Open issues and decisions"Duplicate invoice dispute open; agreed to wait for the finance team's audit (session 41)"Until resolved, then summarised
EpisodesOne record per session: topic, outcome, follow-upsMonths, compacted over time

Not kept: secrets, payment details, anything another system owns (contract terms, prices, entitlements, which are read live), and inferences about people the customer did not state.

Write path. The assistant proposes memories through a tool during the session; a post-session step proposes more from the transcript. The harness attaches scope, basis, source session and turn, and expiry; screens for secrets; and holds proposals derived from untrusted content (forwarded emails, attachments) for review.

Read path. Each request gets a slice built within a budget, highest priority first:

PRIORITY = {"constraint": 0, "preference": 1, "open_issue": 2, "fact": 3, "episode": 4}

def memory_slice(records, contact, budget_tokens=600):
    visible = [r for r in records
               if r["status"] == "active" and r["contact"] in (None, contact)]
    visible.sort(key=lambda r: (PRIORITY[r["kind"]], -r["confirmed_ts"]))
    out, used = [], 0
    for r in visible:
        cost = len(r["text"]) // 4 + 8          # rough tokens, plus the age label
        if used + cost > budget_tokens:
            break
        out.append(f'{r["text"]} ({r["basis"]}, {r["age"]})')
        used += cost
    return out

recs = [
    {"kind": "episode", "text": "S40: invoice dispute raised", "status": "active",
     "contact": None, "confirmed_ts": 40, "basis": "session", "age": "3 weeks"},
    {"kind": "preference", "text": "Priya prefers calls", "status": "active",
     "contact": "priya", "confirmed_ts": 12, "basis": "stated", "age": "4 months"},
    {"kind": "open_issue", "text": "Duplicate invoice: waiting for audit",
     "status": "active", "contact": None, "confirmed_ts": 41,
     "basis": "agreed", "age": "2 weeks"},
]
first = memory_slice(recs, "arjun")[0]
print(first)  # => Duplicate invoice: waiting for audit (agreed, 2 weeks)
print(len(memory_slice(recs, "priya")))  # => 3

Arjun's session never sees Priya's contact preference; Priya's sees all three, preference first. Older episodes are available through a memory_search tool rather than injected.

Correction and control. "We moved summaries to Mondays" supersedes the Friday record and keeps it for audit. The customer's admin can see what is remembered and delete any of it; deletion follows record ids into the vector index and any summary built from it.

Measurement. Compare sessions with memory on and off (or a holdout of accounts) on resolution rate, turns to resolution and how often customers repeat information. Watch for harm too: actions taken on stale memories, corrections per hundred memories.

What interviewers probe next

"Six months of episodes is a lot. What happens to them?" Older episodes are compacted into account-level summaries rebuilt from active records, and the originals expire on the retention schedule.

"A contact leaves the company." Their contact-scoped memories are retired; account memories they authored stay, with author recorded, unless policy says otherwise.

"What stops memory from making the assistant overconfident?" Rendering age and basis, and requiring live reads for anything consequential. "Waiting for audit (2 weeks)" invites a check; a bare "waiting for audit" does not.

What if?

What if · interview follow-ups

Hold your answer as the constraints change

Your assistant has six months of memory for one customer account with several contacts.

  1. Start here

    What if a forwarded email in a session says 'the customer has approved auto-renewal'?

How it's scored

Weak: A vector database of all past conversations, searched on every turn.

Hire: Kinds of memory with write and read policies, scoping and expiry.

Strong Hire: Account and contact scopes from the session, kinds with lifetimes, exclusion of system-of-record data, a screened and tainted write path, a prioritised budgeted read with age and basis, supersession and customer-visible deletion, and a holdout comparison with harm metrics.

Common mistakes

  • Storing copies of contract terms and prices that change elsewhere.
  • One scope for the whole account, so contacts see each other's preferences.
  • No path for the customer to see or remove memories.
  • Measuring only that memory is used, not whether outcomes improve.
You just read a free answer. Every topic opens its first 5 answers to anyone. Sign in and the count per topic goes to 6, and the site remembers where you stopped in each one.Google sign-in · free · no payment details
HOW DID IT GO?
0
READING SIGNED OUT

Signing in raises your free answers from 5 to 6 per topic, adds an applied lesson in every topic and easy practice tests, and the site starts remembering you: mastery per topic, bookmarks, and a next-focus recommendation. Free, no card.

Sign in free
UP NEXT ON YOUR JOURNEY
DISCUSSION · 0

Nobody has commented. Post a correction or another way to answer.