What is AI conversation history?
Conversation history is the ordered record of previous user messages and model replies in a chat-based AI application; since the model keeps no state between requests, it is added back into the context window with each new request so the conversation can continue.
Unlike long-term memory, selected and summarised information kept across sessions, conversation history carries one session's messages as they are and ends with it. The model does not remember earlier messages itself; the application sends them.
- Topic
- Prompts, context, reasoning and generation
- Also known as
- Chat history
How AI conversation history works
- Each message is stored with its role: system, user or assistant.
- On a new request, the history is formatted to the model's chat template and sent with the new message.
- When it exceeds the context window, the oldest messages are dropped, summarised or only relevant parts selected.
- If history is stored, access, retention period and deletion rules are set.
In more detail
Prefix caching versus history compaction
Because prefix caching reuses KV states only when the leading message sequence is byte-for-byte identical, appending new turns is much cheaper than mutating earlier turns. Triggering rolling summarisation or sliding-window truncation on every turn breaks prefix cache hits; in production, teams often compact history only at coarse checkpoints (for example, every N turns or when the window is mostly full).
Managing tool results and reasoning traces
Modern chat histories include structured tool-call and tool-result messages alongside user and assistant turns, while reasoning models also emit intermediate thinking tokens. Retaining raw tool payloads (such as full API JSON dumps) or unpruned reasoning traces inside history rapidly bloats the context window, so production apps prune stale tool outputs and strip intermediate thinking blocks between turns.
Multi-turn context poisoning, error propagation and crescendo attacks
Erroneous claims, hallucinations or injected instructions accepted in an earlier assistant turn stay in conversation history and steer subsequent replies (context poisoning and error cascading). Similarly, multi-turn jailbreaks (such as Crescendo attacks) gradually shift framing across turns to bypass safety filters that would catch a single-turn request.
Stateless models versus server-side session APIs
While LLMs themselves remain stateless, many modern serving layers offer stateful session/conversation APIs that store turn histories server-side under a session ID. Even then, the underlying model still receives the compiled history inside its context window, so access control, encryption at rest and explicit TTL deletion rules remain essential.
Commonly confused terms
| Term | How it differs |
|---|---|
| RAG context | Conversation history sits in the user/assistant dialogue turn array inside the context window, whereas RAG retrieves external verified documents from a knowledge base at query time to ground the reply. |
| Agent state | Conversation history tracks dialogue turns inside a single interaction thread; agent state / execution scratchpad tracks intermediate tool calls, structured variables, plan steps and branching workflow state across autonomous steps. |
Why AI conversation history matters for on-premises AI
Conversation history underpins multi-turn assistants and chat-tuned models are trained for it, but resending the whole history each turn grows token cost and latency. A study of long contexts showed models perform best when relevant information is at the start or end of input and markedly worse in the middle, so information mid-history can be missed. History contains personal data and business information, so where and how long it is kept also needs to be governed.
A bank's customer assistant keeps conversation history only for the session; as it grows, older turns become a short summary, history is deleted when the session closes and only a masked log is kept for audit.
Common questions
Does the model remember earlier messages itself?
No. It keeps no state between requests; the application resends the history each time.
What happens when history exceeds the context window?
Old messages are dropped, summarised or filtered to relevant parts; otherwise the request is rejected or truncated.
Related terms
- Context window
- AI chat template
- System prompt
- AI long-term memory
- Context compression
- AI lost in the middle
Sources
- Lost in the Middle: How Language Models Use Long Contexts, 2023
- Llama 2: Open Foundation and Fine-Tuned Chat Models, 2023
In the glossary: Glossary, A to D