AI Engineering Interview Questions: Agent Memory

Reviewed by Mark Dickie · Last updated

Agent memory is the mechanism by which an AI agent stores, retrieves, and updates information across multiple steps of a task, enabling it to reason over context that does not fit in a single prompt or persist across sessions. For an AI engineering interview, you should know the three main memory tiers (short-term, long-term, and episodic), how retrieval-augmented memory differs from raw context-window stuffing, and the trade-offs between vector stores, key-value caches, and structured databases for agent recall. Interviewers also test whether you understand memory consolidation, forgetting policies, and how to prevent context bloat from degrading agent performance over long-running workflows.

What does an AI agent memory interview test?

Interviews on agent memory typically probe your ability to design a memory architecture, justify storage choices, and reason about failure modes like stale recall, hallucinated memory, or unbounded growth. You may be asked to sketch how an agent retrieves relevant past interactions without re-reading an entire transcript, or how to version memory when an agent's goals change mid-task.

Memory typeTypical storageRetrieval methodLifetime
Short-term / workingContext window, scratchpadDirect (already in prompt)Single turn or task
Long-term / semanticVector database, document storeEmbedding similarity searchPersistent across sessions
EpisodicEvent log, transcript storeTemporal or causal queryBounded by retention policy
ProceduralTool-use history, cached plansPattern match on task typeUpdated as skills improve

How should I prepare for agent-memory questions?

  1. Study the read/write lifecycle: when an agent encodes a new memory, when it retrieves one, and when it updates or deletes an existing entry.
  2. Compare retrieval strategies — dense vector search, BM25 keyword lookup, structured SQL queries — and know when each is the right choice for a given agent design.
  3. Practice designing a forgetting policy: time-based decay, relevance scoring, or hard capacity caps, and be ready to explain the trade-off between recall quality and cost.
  4. Understand how memory interacts with tool use and planning, since agents that call external APIs need to store tool results in a way that stays queryable later.

What are common agent-memory failure modes?

Context bloat is the most frequent: as memory grows, retrieval latency rises and irrelevant results crowd out useful ones. Stale memory causes agents to act on outdated facts. Hallucinated recall happens when a retrieval system returns a loosely related chunk and the agent treats it as ground truth. Each of these has concrete mitigations — capacity limits, versioning, and confidence scoring — that interviewers expect you to name and defend.

Key facts

  • Tarmac has 42 AI Engineering interview questions on this topic, 10 of them on this page, at difficulty 1–5 of 5.
  • Tarmac last reviewed these AI Engineering interview questions on 23 August 2026.

At a glance

Questions10 shown · 42 in the bank
Difficulty1–5 of 5
FormatsTrue / false, Fill in the blank, Flashcard, Multiple answer, Find the bug, Multiple choice, Short answer, Coding exercise, Ordering
Interactive1 run your code against tests, in the app

What you'll review

  1. agent memory
  2. agent loops
  3. agents

Practice questions

AI Engineering/agents/agent-memory

A vector database used as an agent's external long-term memory can store and retrieve information from previous conversation sessions, not just the current one.#

Options

Show answer

True. A vector database used as an agent's external memory persists embeddings of past interactions to disk. This means the agent can retrieve relevant information from previous conversation sessions — not just the current one — effectively providing long-term memory that survives context window resets.

Why:

Vector databases (e.g., Pinecone, Chroma, Weaviate) persist embeddings of past interactions or knowledge on disk. An AI agent can query this store at the start of or during a new session to retrieve relevant memories from prior sessions, effectively giving it long-term memory that survives context resets.

AI Engineering/agents/agent-memory

The two most fundamental memory scopes for an AI agent are _____ memory (held in the active context window, lost after the session) and _____ memory (persisted in external storage across sessions).#

Show answer

The two most fundamental memory scopes for an AI agent are short-term memory (held in the active context window, lost after the session) and long-term memory (persisted in external storage across sessions).

Why:

Agent memory is most commonly categorized into short-term (in-context) memory — information held within the LLM's active context window that disappears when the session ends — and long-term (persistent) memory — information saved to external storage such as databases or files and retrievable across multiple sessions. Understanding these two scopes is foundational to designing memory-aware agent architectures.

AI Engineering/agents/agent-loops

What belongs in an agent's persistent memory, as opposed to its within-run context?#

Show answer

Facts that outlive the run and change how a future one should start: stated preferences, decisions already made and why, outcomes of past runs, stable facts about the user or account. Not the transcript — storing whole conversations gives you a pile nobody can retrieve from usefully, and replaying it reintroduces the context problem you just escaped. Write deliberately at the end of a run, keep entries small and attributed, and retrieve selectively rather than loading everything. Treat it as data with a lifecycle: memory that is never revised becomes confidently wrong when a preference changes, and stale memory is harder to spot than absent memory.

Why:

The distinction that matters is durability. Within-run context is working state that dies with the run; persistent memory is the small set of conclusions worth carrying forward. Teams usually get this wrong in one of two directions — persisting nothing, which produces an agent with amnesia between sessions, or persisting everything, which produces a store too large to retrieve from and full of superseded facts. The staleness point is the one most often missed: a remembered preference that was true in March and is quoted back confidently in September is worse than having remembered nothing.

AI Engineering/agents/agent-memory

An AI agent framework separates memory into four tiers: in-context (working) memory, episodic/external memory (vector store), semantic memory (knowledge base), and procedural memory (learned skills/tool policies).#

Options

Pick every one that applies.

Show answer

The correct statements are: (a) in-context memory is bounded by context length and is lost between sessions unless rebuilt; (b) a vector-DB episodic store enables efficient semantic retrieval without stuffing full history into the prompt; and (d) semantic memory in an external store can be updated at runtime without touching model weights. Procedural memory encoded as a JSON blob in every prompt is wasteful and brittle, and KV caches are not session-persistent across independent API calls.

Why:

Agent memory architectures are typically decomposed into four distinct tiers that serve different temporal and functional purposes. In-context (working) memory is the active prompt window — cheap to read but bounded by context length. External/episodic memory (e.g., a vector store of past episodes) allows retrieval across unlimited history but requires an explicit lookup step. Semantic/knowledge memory stores structured facts the agent can query. Procedural memory encodes learned skills or tool-use policies, often baked into weights or fine-tuned adapters — NOT the in-context window, which is stateless across sessions. The statement that in-context memory persists across independent agent sessions is false: a fresh invocation starts with an empty context unless explicitly reconstructed from an external store.

AI Engineering/agents/agent-memory

The following function is intended to retrieve relevant memories from a vector store and inject them into an agent's system prompt. It runs without raising an exception but the agent always behaves as if it has no memory. Identify the single buggy line.#

from langchain.vectorstores import FAISS
from langchain.embeddings import OpenAIEmbeddings

def build_memory_context(query: str, vectorstore: FAISS, k: int = 5) -> str:
    """
    Retrieve the top-k relevant memories and return them as a formatted string.
    """
    results = vectorstore.similarity_search(query, k=k)
    snippets = []
    for doc in results:
        snippets.append(doc.content)          # line 10
    memory_context = "\n".join(
        f"- {s}" for s in snippets if s
    )
    return memory_context if memory_context else "No relevant memories found."
Show answer

The bug is on line 10.

Why:

The bug is on line 10. results is a list of Document objects returned by LangChain's similarity_search; each document's text content lives in doc.page_content, not doc.content. Accessing .content returns None (or raises AttributeError depending on the version), so memory_context is assembled from None values and the agent receives no useful context. The fix is to replace doc.content with doc.page_content.

AI Engineering/agents/agent-memory

You are designing the memory-write policy for a long-running autonomous agent that executes multi-step tasks over hours. The agent uses a vector store as its episodic memory. Which write strategy best balances retrieval precision, storage efficiency, and resilience to interruption?#

Options

Show answer

The best strategy is to run a periodic summarisation step — after every N turns or at key decision points — that compresses recent context into a structured memory object and upserts it to the vector store. This approach keeps the store compact and semantically dense (improving retrieval precision), avoids flooding it with low-signal raw turns, and still checkpoints progress frequently enough to survive task interruptions — unlike buffering everything in RAM until completion.

Why:

Agent memory architectures must make a deliberate choice about when to write to long-term memory. Writing after every single LLM turn (option A) floods the store with low-signal noise and degrades retrieval precision. Writing only at task completion (option C) risks losing context if the task is interrupted. Periodic summarisation with a dedicated memory-consolidation step (option B) is the established best practice: it mirrors the human sleep-consolidation model, reduces store size, and keeps retrievable memories semantically rich. Storing only tool-call logs (option D) omits the reasoning and observation content needed for rich episodic recall.

AI Engineering/agents/agent-memory

An agent runs for hundreds of turns and its transcript no longer fits in the model's window. How do you keep it working without losing the information it needs? Name the main techniques.#

Show answer

Stop sending the full raw transcript and instead manage what occupies the window. The common techniques: summarize/compact older turns into a running summary while keeping the most recent turns verbatim; offload the full history to an external store (a vector database or scratchpad) and retrieve only the passages relevant to the current step; prune or evict low-value turns (tool spew, stale intermediate results); and keep the durable facts (the goal, key decisions) pinned in a compact memory block. The point is to compress and select, not to assume a bigger window will save you.

Why:

Long-running agents survive by managing the window rather than enlarging it. Two complementary moves dominate: (1) compaction — replace older turns with a running summary, keeping recent turns verbatim; (2) externalize + retrieve — persist the full history to an outside store and pull back only what's relevant to the current step (RAG over your own transcript). Supporting tactics: prune/evict low-signal turns, and pin durable facts (goal, decisions, constraints) in a small always-present block. Simply 'use a model with a bigger context window' defers the problem and raises cost/latency; the win is compressing and selecting what the model actually needs to see.

AI Engineering/agents

You split a task across a supervisor agent and several worker agents that pass results back and forth. Compared to a single well-scoped agent, which of these are genuine failure modes that multi-agent systems introduce? Select all that apply.#

Options

Pick every one that applies.

Show answer

Genuine multi-agent failure modes are coordination overhead — extra tokens and rounds spent on hand-off can outweigh any parallelization gain, especially on sequential work — error compounding, where a downstream agent trusts an upstream agent's wrong result without re-verifying it, and context pollution, where shared or forwarded history carries one agent's mistaken assumptions into another agent's context. Splitting a task across more agents does not guarantee higher accuracy — it can just as easily amplify errors — and multi-agent chains do not implicitly validate each other's output; assuming the next agent will catch a mistake is exactly how errors compound silently.

Why:

Real, documented multi-agent failure modes are coordination overhead — extra tokens and rounds spent on hand-off can outweigh any parallelization gain, especially on tasks that are fundamentally sequential rather than genuinely parallelizable (a); error compounding — a downstream agent trusts an upstream agent's wrong or hallucinated result without re-verifying it, so mistakes propagate and can amplify rather than cancel out (b); and context pollution — shared or forwarded history carries one agent's mistaken assumptions or stale state into another agent's context (c). (d) is false: more agents does not guarantee higher accuracy — it can just as easily amplify errors, and reliably improving quality requires explicit structure like verification steps, not headcount. (e) is false and dangerous: assuming 'the next agent will implicitly catch it' is precisely the assumption behind the error-compounding failure mode in (b) — an implicit downstream glance is not an actual validation step, so chaining agents with no explicit check is exactly how bad results silently propagate.

AI Engineering/agents/agent-loops

Implement trim_history(messages, max_messages). Each message is a dict with role, content and pinned (bool). Pinned messages carry the system prompt, the tool schemas and the goal — dropping them is what makes an agent forget what it was asked to do.#

Starter code

def trim_history(messages, max_messages):
    # TODO: keep the pinned messages, then the newest unpinned ones that fit
    return messages[-max_messages:]

Your solution must pass

  • nothing to trim
  • keeps the system message and the newest turns

This one is written and run, not read. Solve it in the app and your code is executed against these tests and the hidden ones.

AI Engineering/agents/agent-memory

An AI agent framework architect is documenting the four canonical memory tiers used in a long-horizon autonomous agent. Arrange the tiers below in order from fastest to access / most ephemeral (first) to slowest to update / most persistent (last).#

Put these in order

Show answer

The correct order from fastest/most ephemeral to slowest/most persistent is: (1) In-context working memory — lives only for the current context window; (2) External semantic (vector) memory — retrieved via ANN search, written in milliseconds; (3) Structured relational/graph memory — exact lookups but schema writes are heavier; (4) Parametric memory (fine-tuned weights) — the most persistent but requires a full training run to update, making it the slowest to modify.

Why:

Memory architecture in autonomous agents involves several distinct tiers, each with different latency, persistence, and capacity profiles. In-context (working) memory is fastest but ephemeral and token-limited; external vector/semantic stores provide large-scale fuzzy recall; relational/graph stores provide structured, exact-lookup long-term memory; and a parametric (fine-tuned weights) tier bakes knowledge directly into the model but is expensive to update. The correct ordering from fastest/most ephemeral to slowest/most persistent is: in-context working memory → external semantic/vector store → structured relational/graph store → parametric (fine-tuned weights). Options that place vector stores before in-context memory, or parametric memory before structured stores, reflect fundamental misunderstandings about write latency and retrieval cost.

Related interview questions

The other 32 questions

This page shows 10. A free account opens the rest and marks your answers, which a page of answers can't do. Miss one and it returns a few days later, then a week after that, until you stop missing it.

Start free

Free · the whole bank · 100 graded answers per 30 days · written feedback and job-ad quizzes on the paid plan

What moved, monthly

One email a month when the bulletin comes out: what moved in the markets we track, and the new question topics we published. Confirm your address to join. Unsubscribe any time.