DEV Community

Cover image for Your chat hits 100 turns. What do you send the model on turn 101? (Friday AI question)
M.T.Ramkrushna
M.T.Ramkrushna

Posted on

Your chat hits 100 turns. What do you send the model on turn 101? (Friday AI question)

Friday AI Question. This one is about the chat that never ends.

A user is 100 turns into a conversation with your assistant. On turn 101, what do you actually send the model?

Pick one (and tell me in the comments):

  • A) Everything. The full history, every turn, until the API complains about the context window.
  • B) A sliding window. Keep the system prompt and the last N turns, drop the oldest.
  • C) Summaries. Compress older turns into a summary and keep recent turns verbatim.
  • D) C, plus engineering. Pinned facts the summary can never drop, clearing old tool results, a token budget enforced in code, and an eval set of long conversations.

My lean is at the bottom. First, why "just send everything" stops working long before the context window runs out.

Fitting in the window is not the same as being used well

Bigger context windows made A look free. Three sources say otherwise:

  • Lost in the Middle (Liu et al., 2023) tested multi-document QA and key-value retrieval and found performance is often highest when the relevant information is at the beginning or end of the input, and degrades significantly when it sits in the middle, even for explicitly long-context models. In a long chat, the middle is where turn 37's important detail lives.
  • Chroma's Context Rot report (July 14, 2025) evaluated 18 LLMs and found performance gets increasingly unreliable as input length grows, even on simple tasks. Its conversational test used LongMemEval: full prompts averaged about 113k tokens of chat history, focused prompts about 300 tokens with only the relevant parts. Across all models, performance was significantly higher on the focused prompts.
  • Anthropic's context engineering guide describes the same effect as "context rot" and frames context as a finite "attention budget": every new token depletes it, so the goal is the smallest set of high-signal tokens.

And there's the bill. OpenAI's conversation-state docs note that even when you chain turns with previous_response_id, all previous input tokens in the chain are billed as input tokens. Server-side state does not make history free.

Quick illustrative math (my example, not a benchmark): if every turn adds roughly 500 tokens, turn 100 resends about 50,000 tokens of history just to answer one new message.

Why B is fragile

A sliding window is cheap and predictable, which is why it's everywhere. The failure is silent: the user's name, their constraint ("never suggest paid plans"), or the decision you made on turn 3 falls off the end, and the assistant confidently forgets it. Nobody gets an error. The answer just gets worse.

Why C needs care

Summarization (Anthropic calls it compaction) is the first lever Anthropic recommends for long-running agents: summarize a conversation nearing the context limit and restart with the summary. In Claude Code, the model summarizes the history, keeping architectural decisions, unresolved bugs and implementation details, and continues with that summary plus the five most recently accessed files.

Anthropic's warning is the important part: overly aggressive compaction can lose subtle context whose importance only shows up later. Their advice is to tune the compaction prompt on real traces, maximizing recall first, then trimming. The lightest-touch version is tool result clearing: once a tool result is deep in history, the raw output rarely needs to be seen again.

OpenAI now documents compaction too (server-side compaction with a compact_threshold, and a standalone compact endpoint), so this is becoming a platform feature, not a hack.

What D looks like in practice

  1. Pinned facts. Keep a small structured block (user preferences, hard constraints, decisions) that is always sent and never summarized away.
  2. Clear old tool output first. It's usually the biggest and least useful part of the history.
  3. Summarize in the background, before you hit the limit, not when a request fails.
  4. Enforce a token budget in code. Count tokens per request and decide what to drop deliberately.
  5. Eval on long conversations. Build a few test chats where a key fact is stated early and asked about late. Run them on every prompt or model change.

My lean

B is the floor, D is the goal. A is fine for short chats, but it fails quietly on long ones, both in quality and cost. If you summarize, test what your summary forgets.

So: A, B, C or D? And what's the longest conversation your eval set actually covers?

References

Top comments (1)

Collapse
 
userxnom profile image
Abdullah Naseer •

D — and your "fails quietly" point is the one I would underline twice. A sliding window does not throw an error when it drops the constraint from turn 3; it just starts giving confident, slightly wrong answers, and in a mobile app the user blames the app, not the context strategy.

The pairing of Lost in the Middle with the Context Rot numbers is what sold me. Fitting 50k tokens in the window is not the same as the model actually using turn 37 when it matters, and your billing note about previous_response_id is the part most people miss — server-side state does not make history free.

One addition I would make to D: version the pinned facts. A user changing a preference mid-conversation is exactly the case where a stale pinned block and a fresh summary disagree, so the system needs a rule for which one wins rather than hoping the summary got it right. That is also the eval I would write first.

What does your long-conversation eval set actually cover — do you include a case where a key fact is stated early, then deliberately contradicted later, to see whether the pinned block or the summary wins?