Memory
Agent memory is application-managed information retained across steps or sessions. It can include temporary state, past events, facts or procedures, with explicit storage and retention rules.
Before you start: Review Lost in the middle first. Python-like examples use variables, lists and functions.
Follow the mechanism
Working state
Hold the current task and recent observations.
Start with an everyday explanation
A scratchpad holds current work; a notebook can hold selected lessons for later. Someone must decide what gets written, who may read it and when to erase it.
See a concrete example
A user preference can persist with consent and expiry. A one-time claim token should not become permanent memory or be shared with another tenant.
A claim to question
Long-term does not mean permanent; short-term state is not automatically wiped at task end.
Try before revealing the answer
Design a memory record with user scope, source, created_at and expires_at. Decide how to correct an outdated address.
Show the worked answer
Authorize access by user, record the source and expiry, replace or invalidate stale facts and remove dependent cached copies. Keep sensitive credentials out of durable conversational memory.
Now explain the idea to someone else using your own example. If you cannot explain a stage, revisit it before moving on.
Engineering details and trade-offs
Separate working context, episodic events, semantic facts and procedural instructions. Store provenance, timestamps, scope and expiry.
Writing memory does not automatically update model weights. Prevent untrusted text from becoming privileged instructions, and provide correction and deletion.
Reason through the example
A user preference can persist with consent and expiry. A one-time claim token should not become permanent memory or be shared with another tenant.
Implement and test
Design a memory record with user scope, source, created_at and expires_at. Decide how to correct an outdated address.
Inspect the reasoning and expected result
Authorize access by user, record the source and expiry, replace or invalidate stale facts and remove dependent cached copies. Keep sensitive credentials out of durable conversational memory.
What to measure
State the expected result before changing a control. Record your inputs, compare the observed result and explain one limit of this model. In a real implementation, test the failure case as well as the normal path.
Answer before reading the reference
What can go wrong with agent memory?
A defensible answer
Stale facts, privacy leaks, cross-user retrieval and memory poisoning can change future actions. Bound writes, attach provenance, isolate users, expire records and evaluate whether stored information improves outcomes.
Prepare the follow-up
How would deletion propagate to summaries, embeddings and backups?
Show follow-up reasoning
Track derived records and deletion dependencies, including summaries and vector indexes. Remove or invalidate searchable copies promptly and define backup expiry and restore handling. Verify that a restored backup does not reintroduce deleted searchable facts without applying the deletion record.
Use the engineering explanation and worked task above to support your response. Identify which assumptions you would need to verify in production.
Choose a practice depth
- New to GenAI
- Define memory with the everyday example and name its key limitation.
- Applied experience
- Explain the example, implementation choice and a measured failure case. Use the exercise as a small design review.
- Senior or systems depth
- Answer the follow-up, compare alternatives and justify an evaluation or rollout plan with operational constraints.
Self-review your answer
0/4 checks selected. This is self-assessment, not an interview score.
Your explanation and revision notes
Loading local notes…