What kinds of memory can an agent have, and how do you implement them?
Agents and tools · Intermediate 3
Short answer
Short-term memory is the conversation and working state in the context window. Long-term memory persists across sessions: facts about the user, past decisions or summaries, stored in a database or vector store and retrieved when relevant. Some systems separate episodic memory (what happened) from semantic memory (what is true). Write memory selectively and let users see and delete it.
Deeper answer
Implementation choices: keep recent turns verbatim and summarise older ones; extract durable facts with a model call after a session and store them with a timestamp and source; retrieve by similarity or by key when a new session starts. LangGraph, for example, separates thread-level checkpoints from a cross-thread store.
The hard parts are deciding what is worth remembering, updating facts that change, and privacy. Storing everything bloats context and can surface stale or sensitive information.
What a strong answer covers
- Short-term memory in the context window
- Long-term memory persisted across sessions
- Retrieves only relevant memories
- Summarising or extracting what to keep
- Privacy, updates and deletion
Answer it out loud in the mock interview about 1.5 min
Follow-ups to expect
- How would you handle a remembered fact that is now out of date?
- What memory would you never store?
Common mistakes
- Stuffing the whole history into every prompt
- No way for users to see or delete memories
Learn it
- What are common failure modes of agents, and how do you guard against them?
- Your agent ran overnight and ran up a large API bill. What probably happened, and what do you change?
- How would you design a harness for an agent that has to work on one task for several hours?
- What is the difference between an agent and a workflow?
- What are computer-use or browser agents good for, and what are their risks?
- What is context engineering, and why does it matter for agents?
- An agent completes a task correctly most of the time but sometimes goes badly wrong. How do you debug it?
- What makes a good tool for an agent?
- Design an agent that handles refund requests for an online store.
- You changed your agent's harness. How do you prove the change made it better?
- What are verification gates in an agent harness, and how would you add them to a coding agent?
- How does tool calling work?
- When should an AI agent ask a human for approval before acting?
- Explain state, nodes, edges and checkpoints in LangGraph.
- What are planning and reflection in agents, and when do they help?
- Two coding agents use the same model, but one solves far more of your tasks. Why could that be, and how would you find out?
- What is an agent harness, and what is harness engineering?
- What is the Model Context Protocol, and why does it matter?
- When is a multi-agent system worth it, and what are the risks?