In this article
  1. Before you start
  2. Why interviewers ask this
  3. Stateless and stateful LLMs from first principles
  4. The Staff-level answer
  5. The rubric
  6. Three variants of this question
  7. Common mistakes
  8. Follow-up questions
  9. Sources

Before you start

This page belongs to the AI agent architecture path, where memory is one of the core design choices.

Why interviewers ask this

A wrong answer here leads to a wrong design. An agent that assumes the model remembers will lose facts the moment the application forgets to resend them, and it will meet a token bill it did not expect. Interviewers ask the question because it separates three layers that are easy to blur: the model, the programming interface in front of it, and the application around both.

A weak answer says "yes, ChatGPT remembers the conversation." A strong answer says the model is stateless between calls, the application owns the state, and the cost of resending grows with the chat. A Staff-level answer separates three different things people call state (the conversation, the KV cache and the prompt cache) and says which of them can change the output. The question is reported by candidates in agent and system design rounds.

Stateless and stateful LLMs from first principles

Stateless
Stateless is a property of an interface that treats every request as independent, keeping nothing from earlier requests, so the caller must send all the context the answer depends on each time.
Conversation state
Conversation state is the record of earlier turns, the alternating user and assistant messages, that an application stores and sends back so the model can answer a follow-up in context.

In plain words

Picture a helper who forgets everything after each phone call. To get a useful answer, you read the whole transcript of your earlier calls aloud every time. The helper replies and forgets again. That is how a stateless model application programming interface (API) works.

The analogy breaks in two places. Reading the transcript costs money per word. And you may edit the transcript, even invent lines in it, and the helper cannot tell.

In one precise sentence: an LLM call is a function from the prompt tokens to a distribution over the next token, with weights that do not change during the call.

The application holds the state and the model only reads itBoxes: a request with the full prompt goes to a model with frozen weights, the app stores and resends history, a KV cache lives inside one request, and a prompt cache reuses a repeated prefix across requests.Requestfull promptModelfrozen weightsYour appstoreshistoryKV cacheone requestPromptcachesameprefixDiagram: Interview Clozo, CC BY 4.0 ·interview.clozo.ai/blog/are-llms-stateful-or-stateless.html

State lives in the application; the caches around the model save compute but add no memory.CC BY 4.0 — source: Are LLMs stateful or stateless?
Step-by-step description
  1. The model reads the whole prompt each call.
  2. The app stores history and resends it.
  3. Working state exists inside one request.
  4. A repeated prefix is reused across requests.
  • The model receives the whole prompt in every request.
  • The application stores the history and resends it.
  • The KV cache lives inside one request.
  • Prompt caching reuses a repeated prefix across requests.

Step 1: The model is a fixed function of its input

The weights of an LLM are fixed once training ends, so nothing a user says in a chat changes the model. Input: a list of tokens. Output: the next tokens. Sampling can make two replies to the same prompt differ, but that is randomness in the output step, not memory of the first reply.

The Hugging Face documentation treats the cache as an inference feature: it says caching should only be used for inference (Hugging Face Transformers, accessed 2026-10-26). Training, which does change weights, is a separate process that never runs inside a chat request.

So "does it remember me?" has a clear answer at the model level: it can only use what is in the prompt it is handed. You now know where memory cannot live. The next step shows where it does live.

Step 2: The application resends the whole history on every call

The application owns the conversation state and sends it again with each request. Anthropic's documentation puts it directly: the Messages API is stateless, so you always send the full conversational history (accessed 2026-10-26). The same page notes that earlier turns need not come from the model at all, so "memory" is simply text the application chooses to include. If the application leaves a turn out of the request, the model cannot see that turn at all, and it answers as though the turn never happened.

OpenAI describes the same pattern: each text generation request is independent and stateless, and in Chat Completions you store the transcript and send the accumulated messages array on each request (both accessed 2026-10-26).

What does resending the history cost?

Resending the history makes the input of each turn grow by one exchange. Take an illustrative chat with a 300-token system prompt, 100-token user messages and 150-token replies. Turn 1 sends 400 input tokens and turn 10 sends 2,650, which over ten turns totals 15,250 input tokens against 1,300 if only new text were sent.1

In this illustrative chat the input per turn grows by 250 tokens, so the resend cost over ten turns is about 11.7 times the new text alone.
Quantity (illustrative)Value
Input tokens at turn 1400
Input tokens at turn 102,650
Total input over 10 turns, history resent15,250
Total input over 10 turns, new text only1,300
Ratio of the two11.73
Resent history makes input grow with every turnGrouped bars of illustrative input tokens at turns 1, 3, 5, 7 and 10: resending history gives 400, 900, 1,400, 1,900 and 2,650, while only new text gives 400 then 100 per turn.Input tokens (tokens)01,0002,0003,000135710Turn numberResent every turnOnly the new tokens4009001,4001,9002,650400100100100100Diagram: Interview Clozo, CC BY 4.0 ·interview.clozo.ai/blog/are-llms-stateful-or-stateless.html
Resending history makes each turn's input larger, while the new text stays the same size.CC BY 4.0 — source: Are LLMs stateful or stateless?
Text description of the diagram
  • Input grows from 400 tokens at turn 1 to 2,650 at turn 10.
  • The new text stays at 100 tokens per later turn.

Input per turn climbs from 400 tokens at turn 1 to 2,650 at turn 10, while the new text stays at 100 tokens per later turn.1 Long histories also hit the context window, a limit the application must manage with trimming, summaries or retrieval; the context rot page covers how quality drops as the prompt fills.

Step 3: A KV cache is state inside one request, not memory

A KV cache is a store of the attention key and value vectors of tokens the model has already processed, which lets it skip recomputing them at each generation step. It is state, but it lives inside one request and holds no new knowledge. Hugging Face explains that the stored pairs are reused for later tokens and that each step appends the new key and value vectors (accessed 2026-10-26).

The cache grows with sequence length. For an illustrative model with 32 layers, 8 key-value heads, a head size of 128 and 16-bit numbers, one token needs 131,072 bytes, so 8,192 tokens need 1 gibibyte and 32,768 tokens need 4.1 The Hugging Face cache guide says this memory can become a bottleneck for long contexts, that quantising the cache cuts memory at a cost in speed, and that undefined disables it (accessed 2026-10-26).

Turning the cache off makes generation slower, not different in meaning. That is the test for "is it memory?": removing it must not change what the model knows.

Step 4: Server-side helpers and prompt caching move the work, not the model

Server-side conversation features store and replay history for you; they do not make the model remember. OpenAI's Responses API can chain responses with previous_response_id, and its migration guide presents this as a way to have OpenAI manage prior response context (accessed 2026-10-26). The same page warns that stable instructions must be resent, because the chain does not carry over the previous top-level instructions.

Prompt caching lowers the price of resending. Anthropic documents that 5-minute cache writes cost 25 percent more than base input, 1-hour writes cost twice base, and reads cost 0.1 times base on most models, with per-model exceptions (accessed 2026-10-26). The standard read multiplier is 0.1; the page's table footnote prices cache reads on Claude Opus 5.5 and Claude Sonnet 5.5 at 0.05 times base.

Real requests are cached only when the prefix reaches the minimum length the documentation sets for each model, and only from a cache breakpoint you mark, so short early turns pay full price. Ignoring that minimum, the standard multipliers give 4,572.5 units against 15,250 for the illustrative chat, about 30 percent of the uncached cost, which is a best case rather than a prediction.1 The request is still stateless: the prefix must be the same, and the context window still applies.

Knowing it is half the job. Saying it is the other half.

Interview Clozo is an AI interview copilot for real interview rounds: it hears the question and puts a strong answer on your screen, and you say it in your own words. See the features or how it works.

Start Free Trial →

The Staff-level answer

Interviewer asks

Are LLMs stateful or stateless?

A strong answer

Stateless between calls, stateful only inside one. The weights are fixed, so every request has to carry the whole context: the system prompt, the earlier turns and the new message. The application owns that state and decides what to resend, so memory becomes a design problem of trimming, summarising or retrieving. Inside a request the model keeps a key-value cache so each new token reuses earlier work, and providers can reuse a repeated prefix across requests, which cuts cost but not the context-window limit. Server-side chaining such as previous_response_id stores and replays the history for you; the model itself is unchanged.

What makes it Staff-level: the answer separates three kinds of state, says which one changes behaviour, and ends on the cost and the limit instead of a definition.

The rubric

A strong answer names who owns the state, and a Staff answer adds the cost, the caches and the context limit.
DimensionWeak answerStrong answerStaff answer
CorrectnessSays the model remembers the chat.Says the model is stateless and the app resends history.Separates conversation state, KV cache and prompt cache.
DepthGives no mechanism.Explains the request carries all prior turns.Explains frozen weights and per-request attention state.
Trade-offsIgnores cost.Notes that cost and latency grow with history.Adds caching, trimming, summaries and retrieval as options.
CommunicationRambles through vendor names.Gives the one-line answer first.Answers in layers, then checks which one the interviewer wants.
Follow-up readinessIs stuck by "what about server-side state?"Knows server state is replayed text.Knows the context window still bounds the replayed prompt.

Three variants of this question

Does the Responses API with previous_response_id make the model stateful?

previous_response_id does not make the model stateful: the service stores earlier output and supplies it as context, which the docs describe as managing prior response context. The model still reads a prompt and has no memory of its own.

Is the KV cache a kind of memory?

The KV cache is working memory for one generation only, not memory across requests. It saves recomputation and can be switched off without changing what the model knows, so it is a speed optimisation, not learned knowledge.

How would you design a memory system for a local on-prem small or mid-sized LM?

Treat memory as application code around a stateless model. Keep a short window of recent turns, a rolling summary of older ones, and a store of durable facts that you retrieve by relevance and place in the prompt. Keep the prompt prefix stable so the serving stack can reuse cached work, and set a token budget so retrieved text never crowds out the question. The agent system design guide places this inside a whole agent, and context folding shows one way to compress long histories.

Common mistakes

  • "The model remembers earlier chats." (wrong) It only sees what is in the request. (right) "The application resends the history; the model reads it fresh each time."
  • "Server-side conversation state means the model is stateful." (wrong) The service replays stored text. (right) "The provider manages state around a stateless model."
  • "The KV cache or prompt caching gives the model memory." (wrong) Both reuse computed work for the same prefix and do not change outputs. (right) "They cut cost and latency; they do not add knowledge."
  • "A chat product with a memory feature means the model itself remembers me." (wrong) As a general pattern, such features keep facts in the application and insert them into the prompt. (right) "The application stores the memory and puts it in the prompt; the weights do not change."
  • "Stateless means the model needs no context." (wrong) It needs full context in every call. (right) "Stateless across calls, context-hungry within each call."

Follow-up questions

Why does a long chat get more expensive on every turn?

Each turn resends all earlier turns plus the new message, so the input grows by about one exchange per turn. In the illustrative chat above, turn 10 sends 2,650 tokens against 400 at turn 1.1 Prompt caching reduces the price of the repeated part.

What happens when the history no longer fits the context window?

The application has to shorten it: drop old turns, summarise them, or retrieve only the relevant pieces. Server-side chaining does not remove this limit for you; see why agents fail on long tasks.

Can a model learn from my conversation?

Not during the call, because the weights are fixed. Anything the model appears to learn comes from text placed in the prompt; changing the weights needs a separate training run.

Does the KV cache last between requests?

By default it covers one generation. Reusing processed prefixes across requests is what provider prompt caching does: in effect, it keeps the work of a prefix beyond one request, for a limited cache duration and only for the same prefix, so the kinds of cache are related. More agent memory questions are in the agentic AI interview questions.

Key takeaways
  • An LLM is stateless between calls: the weights are fixed and each request must carry the full context.
  • The application owns conversation state and resends it, so input cost grows with every turn.
  • A KV cache is working state inside one request that saves compute and adds no memory.
  • Prompt caching and server-side chaining reduce cost or effort, but the model and the context window limit stay the same.

Sources

  1. Using the Messages API (multiple conversational turns) — Anthropic, Claude Platform Docs, 26 Oct 2026
  2. Conversation state — OpenAI API docs, 26 Oct 2026
  3. Migrate to the Responses API — OpenAI API docs, 26 Oct 2026
  4. Prompt caching — Anthropic, Claude Platform Docs, 26 Oct 2026
  5. How caching works (KV cache) — Hugging Face Transformers documentation, 26 Oct 2026
  6. Cache strategies — Hugging Face Transformers documentation, 26 Oct 2026