AI Engineering interview questions on agent memory

Reviewed by Mark Dickie · Last updated

5 questions on this page you can answer and see marked on the spot. Go to the first one

Agent memory is the set of mechanisms that let an LLM agent carry information across turns, tool calls and sessions, because the model itself keeps no state between requests. For interviews, you should name each memory layer, say where it is stored, and explain what gets lost when it is trimmed. Expect follow-ups that go past the definition: a rolling summary that drops a user constraint, retrieval that returns a stale fact, and how you would prove the agent behaves differently with memory on. Good answers tie each choice to a concrete cost such as tokens per call, latency, or a privacy boundary.

Which memory layers should you be able to explain?

LayerWhere it livesFailure mode to name
Context bufferRaw message list sent with each model callOldest turns are silently cut once the token budget fills
Rolling summaryModel-written digest prepended to the promptThe summariser drops a constraint the user stated once, early on
Vector recallEmbeddings in a store such as pgvector or ChromaTop-k results surface stale facts that outrank newer ones
Structured profileKey-value or table rows, such as a user's timezoneTwo writes overwrite each other with no timestamp or source turn
Episodic logAppend-only record of past runs and tool outputsThe log grows without limit and retrieval pulls in irrelevant runs

What should you practise by hand before the interview?

  1. Write a buffer that trims by token count using the tokenizer your model actually uses, then test a message that is one token over the limit.
  2. Add a summary step that runs every few turns, and keep a test that checks a stated constraint survives several compactions.
  3. Give the profile store a timestamp and source turn on every write, then decide which value wins when two writes conflict.
  4. Score recall on a set of questions you wrote yourself, with the vector store on and off, and count which answers change.
  5. Replay a saved session with memory cleared and note exactly which responses diverge, and why.

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 tracked 2,397 job postings asking for AI Engineering in November 2026.
  • Roles asking for AI Engineering advertise a median base salary of £80,000, across 622 job postings as of November 2026.
  • Tarmac last reviewed these AI Engineering interview questions on 7 November 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

Try one before you open the answer. Pick an option and press Check; it's marked on the spot.

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.

In LLM agent design, one common two-scope split of memory is: _____ memory (information held in the model's active context window, lost when the session ends) and _____ memory (information saved to external storage such as a database or file and retrievable across sessions).#

Show answer

In LLM agent design, one common two-scope split of memory is: short-term memory (information held in the model's active context window, lost when the session ends) and long-term memory (information saved to external storage such as a database or file and retrievable across sessions).

Why:

Agent memory is often described as a split between information that lives inside the model's active context window and is discarded when the session ends (in-context, short-term or working memory), and information written to external storage such as a database or file that can be retrieved in later sessions (long-term, persistent or external memory). Both blanks accept the standard synonyms for each scope, so any of these wordings is correct.

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.

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: in-context memory is bounded by context length and is lost between sessions unless rebuilt; a vector-DB episodic store enables efficient semantic retrieval without stuffing full history into the prompt; and 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.

The function below (LangChain 0.2+, using langchain_community) is meant to retrieve relevant episodic memories from a FAISS vector store and format them for an agent's system prompt. The ingestion job writes every memory document with metadata {"type": "episodic"}. The function runs without raising an exception, yet the agent always behaves as if it has no memory, even when the store is populated. Identify the single buggy line (1-based line numbers).#

from langchain_community.vectorstores import FAISS

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 = [d for d in vectorstore.similarity_search(query, k=k) if d.metadata.get("type") == "memory"]
    snippets = []
    for doc in results:
        snippets.append(doc.page_content)
    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 5.

Why:

Line 5 is the bug. It keeps only documents whose metadata type equals "memory", but the ingestion job writes "episodic", so the list comprehension is always empty. The loop on the following lines never runs, memory_context stays empty, and the fallback string "No relevant memories found." is returned on every call. Nothing raises, which matches the reported symptom. The other lines are correct: similarity_search returns Document objects, whose text is in page_content, and the if s filter and join are fine. The fix is to compare against "episodic" or remove the metadata filter.

An autonomous agent runs multi-step tasks for hours and uses a vector store as its episodic memory. Requirement: if the process crashes at any point, the agent should lose at most the single step that was in progress, and each stored record must contain that step's reasoning and observation so the agent can resume. Which memory-write policy meets this requirement?#

Options

Show answer

Write each completed step to the vector store as soon as it finishes, including its reasoning and observation. Because every finished step is already persisted, a crash loses at most the step in progress and the stored records keep enough detail to resume. Batching writes until completion or summarising every N turns leaves finished work unsaved or lossy.

Why:

The requirement has two parts: a crash may lose only the in-flight step, and each stored record must keep the reasoning and observation needed to resume. Writing each completed step with its full content immediately after it finishes satisfies both, because everything finished is already durable. Buffering until task completion loses the whole episode on a crash. Periodic summarisation leaves up to N-1 recent turns unsaved and replaces their detail with a lossy summary. Storing only tool-call names and return codes drops the observations and reasoning that resumption requires.

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.

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; 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; and context pollution — shared or forwarded history carries one agent's mistaken assumptions or stale state into another agent's context. The claim that more agents guarantees higher accuracy 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. The claim that multi-agent systems eliminate the need for output validation is false and dangerous: assuming 'the next agent will implicitly catch it' is precisely the assumption behind the error-compounding failure mode — an implicit downstream glance is not an actual validation step, so chaining agents with no explicit check is exactly how bad results silently propagate.

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.

An agent designer is comparing where a single new fact can be written in an autonomous agent's memory. Arrange these stores from cheapest to write a new fact (first) to most expensive to write a new fact (last).#

Put these in order

Show answer

Cheapest to most expensive to write a new fact: in-context working memory, then a structured relational or graph database, then parametric memory in model weights. Appending to the prompt involves no storage write, a database insert is one durable transaction, and changing weights requires a fine-tuning training run.

Why:

The cost of writing one new fact rises with how much machinery the write requires. Appending an observation to the prompt of the current LLM call is a string operation in memory with no storage I/O, so it is cheapest. Inserting a row into a relational database is a single durable, transactional write, typically a network round trip taking milliseconds. Changing parametric memory requires a gradient-based fine-tuning run over training data, which means GPU compute, data preparation, and evaluation, so it is the most expensive. The ordering follows the write path's cost, not retrieval speed or persistence, so each adjacent pair is clearly ordered.

Related interview questions

Job market

See ai-engineering salaries and hiring demand from live job postings.

The other 32 questions

This page shows 10 and marks what you pick. That's as far as a page can go. A free account opens the other 32 and keeps every answer. What you miss comes back until it's right: after a day, then at longer gaps.

Start with this topic

Free · the whole bank · 100 answers per 30 days, each marked with written feedback

Interview booked? Practise the job ad instead

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.