Context & Memory Interview Questions (2026)

Covers what you send a model and what it costs you: tokens, the context window, context engineering and prompt caching — then agent memory, the separate system that makes anything persist beyond a single request. See also all interview topics. These assume you already know the concepts. If one is unfamiliar, read its linked concept page first — the questions test judgment on top of a concept, not the concept itself. For the definitional counterpart — the "what is X" questions an interviewer usually opens with — see LLM interview questions.

In this guide
  1. Token
  2. Context Window
  3. Context Engineering
  4. Prompt Caching
  5. Agent Memory

Token

Full concept page →

Your app quotes users a price by counting words and multiplying. Non-English users keep reporting bills far above the quote. What's wrong?

Word count isn't token count, and the gap is much wider for some languages than others. A tokenizer is built by merging the character sequences that appear most often in its training text, and that text is overwhelmingly English. Common English words earn a dedicated single token; text in a language that never got that treatment splits into many more tokens to say the same thing.

Script matters on top of frequency, which is why Korean fares far worse than German even though both are minority languages in that training text. When no merge rule covers a sequence, the tokenizer falls back to raw bytes — and a Latin character is one byte where a Cyrillic one is two and a CJK one is three.

Code, URLs and unusual proper nouns hit the same problem for the same reason. Estimate with the actual tokenizer for the model you're calling rather than any words-to-tokens ratio — the ratio is a rough guide for ordinary English prose and nothing more.

A requirement says every generated summary must come out at 140 characters or fewer. A colleague wants to handle it by putting "keep it under 140 characters" in the prompt. Why won't that hold?

The model isn't counting characters and can't easily. What it generates is tokens — chunks of several characters at a time — so an exact character budget is something it approximates rather than measures. It'll land under 140 most of the time and overshoot sometimes, and "sometimes" is a defect when the field has a hard limit.

That's the general shape of character-level work: counting, truncating, reversing, redacting by position. Reasoning models do better by spelling things out step by step, but that's an expensive workaround for something a length check does exactly and for free. Have the model write the summary; have code enforce the limit.

Context Window

Full concept page →

Your chat app has been running for hours. The model suddenly seems to forget something from early in the conversation. What's actually happening?

The context window filled up, and the earliest turns got pushed out to make room for new ones. The model isn't forgetting in any psychological sense — it simply never receives that text anymore. Nothing about a conversation is stored on the model's side between requests; if the application didn't resend it, it isn't there.

Your model now supports a context window ten times larger than before. Should you just retrieve everything relevant and stuff it all in, instead of carefully picking the best chunks?

Not automatically. Fitting is necessary but not sufficient — research on long-context use shows models use information near the start or end of a prompt more reliably than information buried in the middle, and every extra token still costs money and adds latency even when it fits comfortably. A bigger window raises the ceiling; it doesn't remove the reason to be selective about what you send.

A request errors out with "prompt too long" instead of just answering with less context. Is that a bug?

No — some systems deliberately fail loudly rather than silently drop part of the prompt, and that's the safer behavior. The alternative, quietly truncating, can drop an early instruction, a fact from a retrieved document, or a tool result the answer depended on — and the application keeps responding as if nothing were missing.

Your RAG pipeline retrieves 50 chunks for a question that only needed 3. What's the actual cost of over-retrieving, beyond it being wasteful?

Every retrieved chunk counts against the same context window budget as the question and the conversation history, so over-retrieving crowds out room for other things, costs more per request, and can bury the 3 chunks that actually mattered among 47 that didn't — which is exactly the situation the lost-in-the-middle effect makes worse.

Context Engineering

Full concept page →

Your agent summarizes its conversation history every 20 turns to save room. Users report it "forgets" decisions they made earlier. What tradeoff have you hit?

Compaction throws information away — that's what it is for — and whatever does the summarizing has to guess which details will matter later. It usually guesses from the wrong vantage point. A choice that looked incidental at turn 12 can be the thing the whole task turns on at turn 60.

A better summarizer isn't really the fix. Keep the things that must survive out of the summarization path altogether: hold decisions, constraints and identifiers somewhere stable that gets re-sent verbatim, and let the summarizer compress only the discussion around them.

Your main agent has built up 40 turns of context and is about to delegate a subtask. What do you pass down to the subagent, and what do you leave behind?

Usually not. Passing everything hands a focused task 40 turns of mostly irrelevant material, which costs tokens on every call that subagent makes and gives it more to be pulled off course by. Give it what its task actually needs, stated explicitly, rather than everything you happen to have.

Say the cost out loud though, because it's real: a subagent that doesn't know something the parent learned can redo work, or contradict a decision already made. Isolation is a tradeoff you're choosing deliberately, so name what crosses the boundary: the goal, the constraints that bound it, the identifiers it needs, and any decision already made that the subtask could otherwise undo. Leave behind the deliberation that produced them.

By the end of a long task, your agent's context is mostly old tool results — API responses, file contents, search output from steps it finished long ago. What should you do about it?

Most tool results stop being useful the moment the step that asked for them is done. What matters afterward is the conclusion drawn from a result, not the raw payload: "the config sets the timeout to 30s" rather than the entire file it came from.

So compact tool output as the task moves on — keep the finding, drop the body. Two cautions. Decide this per tool rather than globally, because some results do stay relevant for the whole task. And keep enough to retrace a step, or you lose the ability to work out why the agent did what it did.

Prompt Caching

Full concept page →

Caching a large system prompt only pays off above some level of traffic. Roughly where is the break-even, and what actually sets it?

Two requests inside one cache lifetime is about where it turns positive. A write costs 1.25x the base input rate at Anthropic's default five-minute lifetime, and a read costs roughly a tenth. One write with no read is 1.25x against 1x uncached — a straight loss. One write plus one read is about 1.35x against 2x — already ahead.

What sets the break-even is the cache lifetime, not your daily volume. Requests per hour is the wrong unit entirely. What matters is whether a second request carrying the same prefix arrives before the entry expires. Steady traffic every four minutes keeps a five-minute entry alive indefinitely; the same daily total arriving as one burst wastes nearly all of it.

The one-hour lifetime doesn't rescue thin traffic either. It doubles the write price, so it needs proportionally more reads to break even — it buys a longer window to find them in, not a cheaper entry.

You added cache markers to your prompt. The bill didn't change and no error came back. What do you check first?

Whether the prefix was even long enough to cache. There's a minimum cacheable length, it varies by model — on Anthropic's API from 512 tokens on some models up to 4,096 on others — and a prompt under it is simply not cached. The marker is accepted and quietly does nothing.

Nothing failing is what makes this hard to spot. The response reports how many tokens were written to the cache and how many were read from it; if both are zero, nothing cached, and that model's minimum length is the first thing to rule out.

Your system prompt has been getting cache hits reliably. You add one new tool to the request and the hit rate drops to zero. Why?

Because a cache entry is matched on everything that comes before it, and tool definitions sit in front of the system prompt. Add a tool and the prefix no longer matches what was stored, so the system prompt has to be written again from scratch.

The order is tools, then the system prompt, then the messages. A change at any level invalidates that level and everything after it. It doesn't run backwards: a new user message at the end leaves a cached system prompt untouched.

Agent Memory

Full concept page →

A conversation is still well within its context window, with nothing dropped yet. Does that count as the system having memory?

No. That's just the current request still holding everything so far in its budget — nothing has been deliberately decided as worth keeping. The moment the session ends, none of it persists unless a separate memory system explicitly saved it first. Memory is what makes something survive on purpose, not what happens to still fit right now.

A team builds a memory system that saves the full raw transcript of every conversation, indiscriminately, to be retrieved later. What's the risk?

It relocates RAG's own over-retrieval problem into memory. A future request can pull back too many saved memories, most irrelevant to the current question, crowding out the ones that actually matter — the same "more retrieved context isn't automatically a better context" problem, just sourced from past conversations instead of a document store.

An agent's memory includes something read from an untrusted document weeks ago, in a session that's long since ended. Why does that still matter today?

Because injected text saved into memory doesn't need its original source to still be around to fire again — a future request that retrieves that memory reintroduces the same untrusted content, now with no obvious link back to where it came from. Stored memory needs the same untrusted treatment on read as anything freshly fetched, not a pass because it already made it into storage.