Multi-Turn Context Is Append-Only: How to Handle Reasoning Cache Invalidation
This article explains why newer LLM interfaces treat conversation history as append-only, how modifying the prefix invalidates cached reasoning states, and what that means for cost, latency, and output quality. It covers which common operations count as prefix modification, why immutable prefixes improve cache reuse, security, and engineering clarity, and how to translate edits into appended entries. A migration checklist, common pitfalls, and a simple validation method help developers redesign context management around immutable prefixes, logged configuration changes, and observability.
1. The Core Shift: From Editable History to Append-Only
Over the past two years, teams building agents around large language models have accumulated a common set of context management techniques: assembling system prompts dynamically per scenario, rewriting the opening based on retrieval results, truncating long tool logs, compressing early turns into summaries, switching structured output modes by task phase, and adjusting the available tool list based on permissions. These practices are reasonable under the assumption that context can be freely edited.
But a rule in the migration notes for a new generation of LLM interfaces changes that assumption: once you modify content before a given point in a multi-turn conversation, all reasoning intermediate states after that point are discarded. Reasoning intermediate states are the intermediate derivation results the model formed in previous turns. After they are discarded, the model must re-derive from scratch, which has two direct consequences: higher token consumption and longer response latency. The official documentation also states that output quality may degrade when reasoning cannot be recovered.
A more important sentence is this: discarding reasoning intermediate states is carried out as part of a security safeguard. This means it is not merely a billing policy or a cache implementation detail, but a security boundary on the platform side. Understanding this is the key to understanding why “going back and editing history” has been systematically closed off.
Typical operations classified as “prefix modification” include:
- Rewriting the developer instructions or system prompt at the beginning;
- Truncating the returned result of a tool call;
- Replacing several earlier turns with a summary;
- Switching models, changing the end user, or changing the owning organization mid-conversation;
- Adjusting request-level configuration such as structured output mode, available tool scope, or reasoning effort.
As long as the change happens in the middle or at the front of the sequence, the reasoning results accumulated afterward are invalidated as a whole.
2. Why Append-Only Is a More Reasonable Design
From a system perspective, immutable prefixes bring three benefits.
First, caches and reasoning states can be reused reliably. Reasoning intermediate states inherently depend on the premise that “the input prefix is exactly identical”; any content change at any position makes the subsequent states meaningless.
Second, the security boundary is clearer. Once context is written, it cannot be tampered with, which is equivalent to leaving a non-repudiable record for each interaction. This makes auditing and compliance checks easier and reduces the room to bypass policy constraints by rewriting history.
Third, the engineering semantics are simpler. The sequence only grows and is never modified, so the client and server naturally share the same understanding of the “current state,” reducing concurrent writes and version conflicts.
The cost is that developers must abandon the habit of “in-place editing” and bring configuration changes into the log stream as well.
3. Migration Essentials: Translating “Modification” into “Append”
The recommended general approach is: keep request-level parameters unchanged, and append all changes as new entries at the end.
| Previous practice | Recommended practice |
|---|---|
| Modify the reasoning effort parameter | Append a configuration update entry at the end; leave request-level parameters untouched |
| Switch the structured output mode | Append it as a configuration update entry as well |
| Adjust the tool list | Append an “available tools addition” entry, or constrain the current turn with an “allowed call scope” |
| Rewrite the developer instructions at the beginning | Append a new developer message at the end |
| Truncate old tool output | Complete the trimming before the first submission to the model, and do not modify it afterward |
The following illustrative pseudocode only expresses the structure and does not point to any specific interface:
input = [{ role: "developer", content: "Fixed rule: output must be valid JSON ..." },{ role: "user", content: "Please review this code" },{ role: "tool", content: "Static checks completed, summary as follows ..." } # trimmed at first injection]# When configuration needs to change, do not go back and edit; only appendinput.append({ type: "configuration_update", reasoning_effort: "high" })input.append({ type: "configuration_update", output_schema: schema_v2 })input.append({ type: "allowed_tools", allow: ["search", "format"] })input.append({ role: "developer", content: "Additional rule: prioritize actionable fix suggestions" })
There is also an easily overlooked detail: in the new semantics, the top-level fixed instruction field is placed after the input. If you want fixed instructions to hit the cache, move them to the first developer message position in the input; otherwise this part will be billed as uncached input. Such “position equals cost” changes often affect the bill more than a parameter rename.
4. Context Management Refactoring Checklist
- Establish a “build once” injection standard. Complete truncation, redaction, and structuring of tool return content before it first enters the context, keeping only conclusions, key fields, and necessary evidence, so that no later changes are needed.
- Move summarization forward. If a conversation may become very long, generate a summary once before approaching the window limit and append it as a new entry, rather than replacing old turns.
- Log configuration changes. Model changes such as reasoning effort, output mode, tool scope, end user, and organization ownership uniformly as append events, making replay and troubleshooting easier.
- Put fixed instructions in the right place. Place long-term stable rules in the first developer message of the input, and express volatile rules as appended messages, balancing cache hits and flexibility.
- Isolate permissions and multiple tenants. Declare switches across end users and organizations through appended entries, avoiding state confusion caused by rewriting history.
- Complete observability. Add instrumentation for each turn’s input length, cache hit status, whether reasoning intermediate states were discarded, retry counts, and latency distribution, and build dashboards and alerts, which can be implemented with general cloud capabilities such as logging services and monitoring and alerting.
5. Common Pitfalls and Validation Methods
Pitfall one: assuming this is only a cache hit rate issue. In fact, it is also a security policy and cannot be solved by “working around” it.
Pitfall two: treating summaries as patches and repeatedly replacing them. Replacement is prefix modification, so the benefit is negative.
Pitfall three: ignoring the position of fixed instructions. A wrong position prevents the stable prefix from being reused and significantly increases cost.
The validation method is simple: construct two groups of requests, one that keeps the prefix unchanged and only appends entries, and another that modifies content in the middle, then compare token usage, time to first token, and output consistency. At the same time, check whether the note in the documentation about quality degradation when reasoning is unrecoverable appears in your scenario. If the difference is obvious, your refactoring direction is correct.
6. Conclusion
Append-only context, append-only configuration changes, and fixed instructions placed first form the baseline of context engineering for the new stage. For developers, the real upgrade is not memorizing a parameter name, but separating “mutable state” from the conversation history and rewriting it as an event stream. This both reuses reasoning intermediate states reliably and controls cost and latency, while making auditing and security boundaries clearer. In the practice of model services on platforms such as Baidu AI Cloud, the same principles apply: first design an immutable prefix, then design append-style changes, and finally use an observability loop to validate the results.
