Skip to content

AI Industry & Models

Context Compaction Cuts Chat Costs but Can Rewrite the Record

Compaction lets a long-running AI chat continue with fewer input tokens. The catch is that instructions, citations, and narrow exceptions can become summaries rather than evidence.

Tobias LundIndustry & Models Writer

November 29, 2026 · 8 min read

Laptop showing a contract review chat beside the original agreement opened to Section 8.2.
Laptop showing a contract review chat beside the original agreement opened to Section 8.2.

Consider a procurement assistant reviewing one software agreement across a long chat. Its standing instruction says not to recommend contracts with automatic renewal longer than 12 months. Section 8.2 contains the termination rule, while a separate security addendum creates a 10-business-day exception to the standard notice period.

After dozens of questions, document lookups, and tool results, that conversation may approach the model’s context limit. Compaction makes continued review practical without resending every old message, but it creates a new failure boundary: the next answer may rely on a condensed account of Section 8.2 rather than the clause itself.

That distinction matters more than whether the assistant remembers the general topic. A useful procurement answer must preserve the controlling instruction, identify the right section, and apply the exception only to the security case. A summary can sound coherent while losing any one of those properties.

What compaction changes

A model’s context is the material supplied for its current response, including system instructions, user messages, assistant replies, retrieved documents, and tool outputs. Models charge and operate on tokens, which are pieces of text, so a growing conversation usually increases the input processed on each turn until old content is removed or the context limit is reached.

Compaction replaces some of that older material with a shorter representation. The implementation may summarize prior messages, discard selected tool results, or create an opaque state item that the vendor’s API can feed into later requests. The next turn receives less text, lowering input-token use and leaving more of the context window available for new work.

OpenAI documents compaction for long-running conversations in its API guidance, including a compacted item intended to carry forward relevant state. Its documentation warns developers to treat the generated compaction output as an implementation artifact rather than editable prose. Anthropic documents a related but narrower mechanism called context editing, which can clear older tool results and other stale context as Claude approaches a configured threshold. Anthropic pairs that feature with a memory tool when an application needs selected information to persist outside the active context.

Those mechanisms should not be treated as interchangeable. Summarizing a conversation can alter how old facts are represented; deleting an obsolete tool result removes it altogether; external memory preserves a selected fact only if the application wrote the right fact to memory. Each route reduces pressure on the context window, but each offers a different answer to what survives.

Prompt caching is different. Caching can reduce the cost or latency of processing an unchanged prefix under a vendor’s documented rules, yet the original tokens still occupy context. Compaction shortens the material presented later, which is why it can extend a workflow rather than merely make repeated input cheaper.

Run the contract test at the compaction boundary

The procurement assistant gives developers a compact acceptance test. Build a synthetic agreement containing four independently checkable elements: the 12-month renewal instruction, the Section 8.2 citation, the 10-business-day security exception, and a later correction that explicitly supersedes an earlier value. Keep the source fixture outside the chat so that the expected answer cannot drift with the model’s retelling.

First, ask questions immediately before compaction and record the answers, the input items, and any retrieved passages. Trigger the same compaction mechanism production will use, then ask semantically equivalent questions immediately afterward. A passing answer must retain the instruction, cite Section 8.2 from original text, limit the exception to its stated scope, and follow the latest correction rather than blending old and new values.

Run that sequence with compaction occurring at more than one point. If the system compacts after the contract was loaded but before the addendum arrived, its state differs from a compaction performed after both documents were discussed, and a second compaction can summarize an earlier summary rather than the underlying messages. Repeated compression is where qualifiers are especially hard to trust, even when the broad conclusion remains stable.

Do not score this test only by asking whether the final recommendation looks right. Record four fields separately: instruction adherence, citation validity, exception scope, and update precedence. A response that reaches the expected conclusion while inventing a section number has failed the evidence test; one that preserves the citation but applies the security exception to every termination has failed the policy test.

Model output varies between runs, so one successful replay establishes little. Repeat the boundary test under the same model settings and with the same source fixture, then repeat it after model, prompt, retrieval, or compaction changes. The useful number is the failure rate for each field, not a single overall impression of answer quality.

What deserves to stay verbatim

The 12-month instruction should remain in a stable developer or system instruction if the API preserves that instruction on every request. Do not rely on an old user message remaining prominent after compaction, particularly when it controls authorization, spending, privacy, or escalation. Applications should reconstruct required instructions from configuration rather than asking the model to remember them from turn 3.

Section 8.2 belongs in a source store with a stable document identifier and location marker. When the assistant needs to make a consequential claim, retrieve the original passage again and include it in the current context. That costs fresh retrieval time and input tokens, but it makes the citation auditable and prevents a compressed paraphrase from masquerading as contractual wording.

The 10-business-day exception needs both its value and its scope. Saving only `notice period: 10 business days` creates a dangerous memory because the condition has disappeared. A structured record should bind the period to the security-addendum trigger, identify its source, and carry the version or effective document state needed to resolve later amendments.

A later correction deserves explicit precedence metadata rather than another conversational sentence. If a user replaces an earlier threshold, the application can mark the old value as superseded and store the current value separately. Compaction may preserve that a correction happened while blurring which number won; application state can make the ordering deterministic.

Not everything merits this treatment. Exploratory questions, discarded drafts, verbose tool traces, and duplicate search results are good compaction candidates because replaying them adds cost without controlling the outcome. The engineering decision is not whether to preserve the whole transcript. It is which parts must remain exact, which can become structured state, and which can disappear.

The savings arrive with an audit cost

Compaction lowers the number of old tokens carried into subsequent turns, so its financial benefit grows with conversation length and the number of later turns. It can also prevent a workflow from stopping at the model’s context limit. Exact savings depend on the vendor’s input pricing, whether cached tokens receive separate treatment, how often compaction runs, and how large the condensed state becomes.

There is overhead. A compaction step may require another model operation or API call, adding latency and usage before later turns become cheaper. Retrieval of pinned source passages adds more work. Logging both pre-compaction and post-compaction state consumes storage, although that log is the only practical way to investigate when the procurement assistant suddenly cites Section 8.

3 instead of Section 8.2.

Opaque compacted state deserves extra caution. If the application cannot inspect the representation, it cannot prove from that item alone that a clause survived accurately. Keep the original transcript and source documents under the application’s retention policy, associate each compacted state with its parent conversation and source versions, and log when compaction occurred. The model-facing context can be short while the audit record remains complete.

The fallback is straightforward. When a post-compaction answer fails a field in the contract test, reload the controlling instruction and original passage, then regenerate from that anchored context. If exact replay matters, start a fresh request from the pinned materials rather than repeatedly compressing the same history.

For casual chat, trusting a summary may be adequate. For the procurement assistant, compaction becomes acceptable only after Section 8.2 is treated as retrievable evidence, the 10-business-day exception is stored with its condition, and the 12-month rule is supplied independently of conversational memory. That setup turns compaction into a cost control rather than an undocumented rewrite.

Questions people ask

Does context compaction change the original chat transcript?

It need not delete the transcript stored by the application, but it changes what the model receives on later turns. Keep the original messages separately if users, auditors, or developers may need to reconstruct why an answer changed after compaction.

Is compaction the same as summarizing a conversation?

Summarization is one possible implementation. Vendor systems may instead remove old tool results, retain selected recent content, or emit an opaque compacted item, so developers should test the documented mechanism they deploy rather than assuming every service creates a readable summary.

Which information should never depend on compressed history?

Keep authorization rules, exact quotations, source citations, narrow exceptions, and superseding corrections outside compressed conversational memory when an error carries operational consequences. Supply standing rules from configuration and retrieve controlling source text again for the turn that uses it.

Can prompt caching replace compaction?

No. Caching can reduce repeated processing cost or latency for eligible unchanged input, but that input still occupies the model’s context window. Compaction removes or condenses material, making additional turns practical while introducing the risk that details no longer survive verbatim.

ShareFacebook
developer toolingai pricing and accessai at workcontext compactionlong-context modelsdeveloper toolingtoken costs

One story a day

The story of the day, in your inbox

One real story about AI each morning — no hype, no alarm, just company for the road.

Read next

A laptop displaying a vendor-risk PDF beside extracted text with matching page labels and a highlighted footnote.

AI Industry & Models

AI Can Read a PDF Page and Still Lose the Document

Rendered pages help multimodal models see tables and diagrams. They do not reliably preserve footnotes, repeated sections, or references that cross page boundaries.

Tobias Lund · 8 min read

A laptop showing a support ticket beside a routing log with accepted and escalated decisions.

AI Industry & Models

A Model Router Saves Money Only If It Escalates in Time

A cheaper model can handle routine work, but one confidently wrong answer can cost more than several escalations. This routing test measures the failure that pricing tables omit.

Tobias Lund · 7 min read

A headset beside a monitor showing a voice call event log and an asynchronously generated transcript.

AI Industry & Models

Speech-to-Speech APIs Cut Delay but Blur the Audit Trail

Direct audio models make interruptions and natural pacing practical. The tradeoff appears when a support team needs searchable calls, fixed moderation rules, or proof of what the model heard.

Tobias Lund · 8 min read