Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Context compaction is a state-reconstruction boundary: it lets a long-running AI agent continue after its context window fills, but an unfiltered summary can make the model’s own plans look like facts. The practical fix is a source-linked checkpoint that protects instructions, records observations with evidence handles, separates decisions from observations, and removes unsupported summary entries before the checkpoint is committed.
This matters whenever an agent edits a repository, calls external tools, or works through a task over many turns. The goal is not to preserve every token. It is to preserve the constraints, evidence, decisions, and unfinished work that the next context genuinely needs—and make it possible to retrieve the raw source when a claim is uncertain.
As an Amazon Associate I earn from qualifying purchases.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsWhat is context compaction?
Context compaction is the process of reducing an agent’s conversation history when it approaches the model’s context limit, then starting the next context with a compressed representation. Anthropic describes context engineering as curating the tokens supplied to a model during inference and defines compaction as taking a conversation near the limit, summarizing it, and reinitiating a new context with that summary. Its guidance recommends preserving architectural decisions, unresolved bugs, and implementation details while dropping redundant tool output or old messages. See Anthropic’s context-engineering guidance for the original definition and examples.
Compaction is therefore not merely deletion. It is a reconstruction step: a new model instance receives a selected account of the old state and must continue from that account. Structured notes stored outside the active context can help the agent reload dependencies after a reset, but those notes need the same discipline as a summary.
Popular on Amazon
- 【90 Degree Full Function USB C Adapter】Supports the latest USB4 standard for up to 40Gbps of bandwidth, 8K video support, and up to 240W Fast charging; Support USB PD 3.1 Extended Power Range (EPR) including 140W, 180W and 240W. Your productivity is easily doubled. *Warm Tip: For the best fit, please make sure the USB-C port is fully exposed; thick or bulky cases may affect compatibility.
- 【Reliable Quality】Made from high-quality, scratch-resistant aluminum alloy, delicate metal frame. get excellent wear resistance and heat dissipation. Non-Slip Design for easier insertion and removal.
- 【Small and portable】Ultra thin size, ultra compact design, a petite physique that matches the minimalist design of your modern laptops. Coming with a slim figure that won't block the port next to the one it's plugged into.
- 【Compatibility】Widely work with most usb c, thunderbolt 4/3 devices. Compatibilit for ROG Ally, Steam Deck, Switch, MacBook Pro, Quest 3 VR headset, Surface Book 2, iPhone 18/17/16/15, Samsung Galaxy S23/S22/S21, Note 20/10, Google Pixel, ChromeBook, etc.
- 【Excellence Customer Support】If you experience any issues or cable failure, simply reach out to our dedicated customer service team. We provide a prompt response within 18 hours, providing you with the necessary technical support to resolve any concerns.
Why do my agent’s decisions become folklore after compaction?
Because a summary is an interpretation, not a neutral transcript. Compaction prompts commonly ask for decisions, next steps, and pending work. The compressor must infer what matters, so it can place a model-generated plan beside facts obtained from tools. After the boundary, the next agent may have no visible distinction between an observed result and an intention invented during summarization.
The University of Virginia’s Source-Judged Compaction study describes this provenance failure. In one example, a constrained request for selected movie titles became a broader instruction to send every title. The summary preserved the compressor’s interpretation, not the user’s original scope.
Recommended Free Tools
- 83% of failed runs in the study were traced to an action carrying out a specific summary entry.
- 67.7% of pending work recorded by the studied compressor had no source in environment outputs.
Those figures are from the study’s workloads, not a universal failure rate. They do show why “memory” needs provenance. An observed file revision, test result, API response, or user instruction can point to an environment output. A plan, assumption, or interpretation generated only by the model cannot. If both are stored in one undifferentiated field, later turns tend to treat the model’s reconstruction as established history.
What should survive an agent context reset?
The next context should receive a compact, typed state rather than a free-form story. Preserve the following categories explicitly:
- Fixed instructions and constraints. Keep system messages, safety rules, permissions, user requirements, output schemas, and non-negotiable limits intact. A compactor must not trade away a constraint merely because it appears old.
- Observed state. Record facts obtained from tools or trusted checkpoints: file contents or revisions, database values, test results, HTTP responses, deployment state, and timestamps.
- Decisions. Store choices separately from observations. Give each decision a status such as proposed, approved, superseded, or verified, and identify who or what approved it.
- Open work. Keep unresolved errors, blocked tasks, and next actions, but label them as work state. “Need to inspect migration 14” is not evidence that migration 14 is broken.
- Evidence handles. Retain enough information to retrieve the original output instead of asking the next agent to trust a paraphrase.
- A recent verbatim tail. Keep the newest interaction or a minimum number of recent message groups unchanged so the next turn has local context and can resolve ambiguities.
Redundant prose, repeated tool output, and stale intermediate reasoning are candidates for removal. The rule is to remove unsupported entries as complete units, not silently rewrite them into stronger claims.
How do I build a source-linked checkpoint?
A source-linked checkpoint is a typed, reviewable record created at each compaction boundary. It should let a later agent answer three questions for every retained claim: what is being asserted, where did it come from, and what authority or status does it have?
Free tools Windows power users keep installed
One-click scans. No signup required.
1. Protect the instruction layer
Keep system instructions and immutable policy outside the ordinary summarization budget. Copy user constraints into a dedicated section with stable identifiers, for example constraint-07. If a later summary conflicts with that section, the constraint wins and the conflict is logged for review.
Also popular on Amazon
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
2. Capture observations with handles
For each environment-established fact, record the tool name, call ID, artifact or file revision, test identity, timestamp, and the relevant output range. A handle can point to an object-store record, a repository commit, a database snapshot, or an append-only tool log. Avoid vague labels such as “the tests passed recently.”
{"kind":"observation","id":"obs-184","claim":"Unit suite passed with 142 tests.","source":{"tool":"ci.run","call_id":"call-8841","artifact":"ci://runs/8841","revision":"git:7f31c2a","timestamp":"2026-11-23T14:08:00Z"},"scope":"commit 7f31c2a only"}
The scope is important. A test result tied to commit 7f31c2a does not automatically describe uncommitted changes or a later branch.
3. Separate decisions from facts
A decision should cite the observations and instructions that support it, but it must remain visibly a decision. Include status, owner, and expiry or supersession information where relevant.
{"kind":"decision","id":"dec-22","text":"Use the existing queue instead of adding a worker process.","status":"approved","based_on":["constraint-07","obs-184"],"approved_by":"user:request-51"}
A proposed approach can be retained, but it should say proposed, not approved. When a later turn changes direction, mark the old decision superseded rather than deleting the history.
4. Label open work and uncertainty
Pending work belongs in a work-state list with an owner and evidence, if any. Distinguish “investigate whether the cache key is stale” from “the cache key is stale.” Preserve unresolved errors verbatim when their exact wording affects recovery.
{"kind":"work_item","id":"work-09","text":"Investigate intermittent 504s on the upload endpoint.","status":"open","evidence":["obs-191"],"hypotheses":["upstream timeout","retry policy"]}
5. Judge every candidate entry before commit
At the boundary, classify each proposed summary entry as supported by an environment output, supported by a trusted checkpoint, or unsupported. Keep supported entries unchanged, retain unsupported items only as explicitly marked hypotheses if your workflow needs them, or remove them. Do not turn an unsupported plan into a factual sentence by adding confident wording.
6. Keep the raw evidence retrievable
Compaction should lower the active token load, not destroy auditability. Store raw tool outputs behind stable handles and make the retrieval operation available to the next agent. If a handle has expired, mark the observation unavailable instead of reconstructing its contents from memory.
Also popular on Amazon
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
What does a provenance gate look like in practice?
A provenance gate is a post-processing layer between a compressor and the next context. It does not need to retrain the model. The University of Virginia study describes Source-Judged Compaction (SJC) as a training-free, drop-in layer that leaves supported entries unchanged, removes entries without an identifiable source, and repeats the check at every boundary. Across AppWorld and OfficeBench, the study reports a 2.1%–8.9% improvement in cross-run reliability without increasing agent token usage. Those are study-specific results, not a guarantee for every agent.
A practical gate can use this sequence:
- Ask the compressor for typed entries rather than one narrative paragraph.
- Require a source handle for every observation, decision rationale, and claimed completion.
- Resolve each handle against the tool log or trusted checkpoint store.
- Reject entries whose source is missing, inaccessible, outside the stated revision scope, or only another unsupported summary.
- Preserve rejected entries in a diagnostic record if needed, but do not place them in the agent’s factual state.
- Attach the newest verbatim message groups and the immutable instruction layer.
- Write the accepted checkpoint atomically, then begin the next context from that version.
Provenance is not a correctness oracle. A summary can cite a real observation and still draw a wrong conclusion. Keep action-time validation—such as checking permissions, current file state, or a destination address—after the provenance gate.
Which compaction strategy should an agent use?
No single strategy fits every workload. Microsoft Agent Framework documentation describes compaction for agents that own an in-memory message list and send the full history on each call. It groups related messages into atomic units, and an assistant tool call must stay with its corresponding tool result. System messages are preserved. The following design menu helps match the mechanism to the risk.
| Strategy | What it does | Strength | Risk or limitation |
|---|---|---|---|
| Truncation | Removes the oldest non-system groups until a token or message target is met. | Simple, predictable hard budget. | Can discard a decision or dependency with no semantic warning. |
| Sliding window | Keeps the most recent turns or message groups. | Bounded history and easy runtime behavior. | Older constraints and evidence disappear unless stored elsewhere. |
| Tool-result compaction | Collapses verbose older tool interactions while retaining a readable trace. | Removes repetitive payload without losing the conversation shape. | A compressed result still needs provenance and revision scope. |
| Summarization | Uses a separate model to summarize older groups, retaining key facts, decisions, preferences, and outcomes. | Preserves semantic continuity across long tasks. | The summarizer can invent, broaden, or misclassify content. |
| Pipeline | Applies tool-result reduction before summarization or truncation. | Gentler reduction and more room for high-value state. | More moving parts and more boundaries to observe. |
Microsoft’s documentation calls these strategies ways to reduce conversation history while preserving important context. In implementation, set the trigger and target separately: the trigger says when compaction starts, while the target says how much history must be removed or summarized. Keep a minimum recent-group floor, protect system instructions, and never split an assistant tool call from its result. See the Microsoft Agent Framework compaction documentation for the documented behavior.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →How should triggers, targets, and message grouping be configured?
Use a trigger below the hard context limit so the compactor has room to operate, and use a target that leaves headroom for the next response and tool calls. The exact token values depend on the model and workload; the important design is the separation between “start now” and “stop when reduced.”
- Group atomically: pair each assistant tool call with its result, and keep related user, assistant, and tool messages together when splitting them would change meaning.
- Set a recent floor: retain enough recent groups to cover the active question, current error, and latest tool result.
- Reserve output space: do not fill the entire context with history; the agent still needs room to reason and act.
- Protect immutable content: system messages, policies, and fixed constraints should not be eligible for deletion.
- Version checkpoints: assign a monotonically increasing checkpoint ID so retries cannot mix entries from different boundaries.
- Make compaction observable: log trigger, target, entries removed, entries retained, source-validation failures, latency, and cache behavior.
When a tool output is huge, store the full payload externally and put a structured digest plus a handle in the active context. The digest should identify the relevant fields, not claim that the entire payload means something it does not say.
Does compaction reduce cost or increase it?
It can do both. Compaction lowers the amount of history sent to later turns, but generating a summary and rebuilding the prompt adds work and can damage prefix-cache reuse.
Also popular on Amazon
- Portable and powerful USB-C HUB: BENFEI USB Type-C HUB, with super-soft and knot-free silicone woven design cable, meets most mobile office needs. Compact, lightweight, stylish, and powerful portable USB C Hub equipped with 1 x HDMI port, 1 x 100W charging, and 3 x USB ports. 18-month warranty, 24-hour response, to ensure you feel at ease when using our product.
- Design centered on comfort and reliability: Thanks to BENFEI's end-to-end in-house cable production capability, in-house PCBA and assembly capability, using the industry's most advanced silicone woven design and process, 20cm cable in length, no knots, super-soft, the HUB is easy to use in all scenarios: laptop, tablet, stand etc. Super-soft, 25000+ life cycles, to meet your daily carrying and office needs.
- 100W Charging: Support up to 90W USB C pass-through charging via Type-C port to keep your laptop powered. 10W is reserved for other interface operations. No data and video function on the Type-C port.
- 4K HDMI Display: The HDMI port supports media display at resolutions up to 4K 30Hz, keeping every incredible moment detailed and ultra vivid. Please note that the C port of the Host device needs to support video output.
- Transfer Files in Seconds: Transfer files and from your laptop at speeds up to 10 Gbps with USB A 3.2 port. Extra 2 USB A 2.0 ports are perfectly for your keyboards and mouse.
The Microsoft Azure Research and UIUC CompactionBench production analysis covers 13.5 million sessions, 3.2 million users, and 760 million LLM calls. Only 7.8% of sessions triggered compaction, yet those sessions accounted for 44.2% of total token consumption. A compaction event reduced the prompt by a median 72.9%, while median cache-hit rate fell from 99.0% before compaction to 27.0% afterward; compaction consumed roughly 22% of a turn’s execution time at the median.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11The paper’s asynchronous APEC design starts summary work at a soft threshold in the background, appends completed summaries to a stable prefix, and keeps a raw recent tail. In its reported evaluation, APEC reduced total cost by up to 25.4% and execution time by 9.6%. Treat those as results for that design and evaluation, not universal savings. A system with short sessions, low cache reuse, or expensive summary calls may see a different trade-off.
How can asynchronous compaction avoid blocking the critical path?
Start compaction before the hard limit, while the current turn is still running, and publish the result only after validation. Keep a stable prefix containing accepted checkpoints and a raw tail containing recent groups. The next request can use the prior stable prefix while a newer summary is prepared; once the new checkpoint is complete, atomically switch to it.
- Soft threshold: estimate the next request’s token demand and enqueue compaction early.
- Snapshot: freeze the message groups selected for reduction so concurrent tool results cannot be silently omitted.
- Summarize and judge: produce typed entries, resolve handles, and reject unsupported claims.
- Publish: append the validated checkpoint to the stable prefix with a new version ID.
- Retain the tail: keep the newest raw groups and any tool call/result pair still needed by the next action.
- Recover: if the job fails, continue with the previous checkpoint and a smaller tail rather than inventing a replacement summary.
Asynchrony changes latency behavior, not the need for provenance. A fast but unsupported summary is still unsafe.
How should compaction be evaluated?
Evaluate the whole task across repeated boundaries, not just the compression ratio. A compact prompt can look efficient while causing a wrong action several turns later.
| Metric | What to measure | Why it matters |
|---|---|---|
| Constraint retention | Required fields, permissions, and non-negotiable limits present after every boundary. | Detects silent loss of instructions. |
| Provenance coverage | Share of retained observations and decisions with valid source handles and revision scope. | Shows whether memory is auditable. |
| Stale-support rate | Claims still supported after files, records, or environments change. | Finds summaries that outlive their evidence. |
| Action violations | Actions that break constraints, measured separately from proposals blocked before execution. | Separates risky execution from safe refusal. |
| End-to-end acceptance | Correct task completion, retries, human corrections, cost, latency, and cache reuse. | Connects compaction to user-visible outcomes. |
| Repeated-boundary resilience | Performance after several compactions in one persistent task. | Exposes failures that a single reset misses. |
CompactionBench notes that many frontier coding benchmarks barely trigger one compaction. A short, single-turn benchmark therefore cannot establish long-horizon reliability. Use persistent multi-turn repository evolution or another workload with executable tests, changing state, and enough turns to force repeated boundaries.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.What are the common failure modes and fixes?
The summary says a plan is complete
Cause: a pending action was phrased as a completed result. Fix: require explicit status fields such as open, in_progress, and verified, and permit verified only with a source handle.
Also popular on Amazon
- 【Read before You Buy】 Note: This adapter is USB 2.0 version and cannot transmit HDM, VGA, or other video signals. Nevertheless, they are fully capable of charging devices,duplicating files, and can be seamlessly integrated with USB-C earphones, wireless network adapters, and SD card adapters.
- 【Easy to Use and Safe】Thanks to modern manufacturing techniques, we've made these adapters sufficiently compact so that they can remain inserted in your device without noticeable protrusion or inconvenience. This means you don't have to constantly plug and unplug them, reducing the likelihood of wear and misalignment, and making them more convenient to carry around.
- 【Reliable Quality】Engineered for enhanced durability, durable aluminum alloy shell material,get excellent wear resistance and heat dissipation,the male USB C and female USB connectors & the male USB and female USB C connectors are designed to be plugged and unplugged up to 20000 times. Provides data transfer, device charging, memory space expansion, and additional computer peripherals.
- 【Think more for you】Do you need to connect a USB-C-enabled device to an odd device that only has USB-A ports? Then these USB-A male to USB-C female adapters are made for you.Simply insert the adapter into the USB-A port on the device, and you can instantly connect your USB-C device to the device that originally didn't have the correct connection port.
- 【Trusted xiwxi Quality and Service】As a responsible brand seller, you will receive xiwxi's 12-month Quality assurance and lifetime friendly customer service, you're not just buying a product,you're investing in peace of mind with all-round quality and exceptional customer service.
A real observation is stale
Cause: the source was valid for an earlier file revision, database snapshot, or environment. Fix: store revision scope and revalidate at action time; if the scope changed, downgrade the entry to stale rather than carrying it forward as current.
A tool call is separated from its result
Cause: truncation or grouping operated at the individual-message level. Fix: compact atomic groups and reject any checkpoint that contains an assistant tool call without its corresponding result.
The agent loses the user’s exact constraint
Cause: the constraint was treated as ordinary conversational prose. Fix: copy it into the protected instruction layer with a stable ID and test for its presence after every boundary.
Cache reuse collapses after compaction
Cause: the new summary changes a previously stable prompt prefix. Fix: append versioned checkpoints to a stable prefix, keep a raw recent tail, and measure cache-hit rate before and after each event.
The provenance gate rejects too much
Cause: tools do not emit durable call IDs or artifact revisions. Fix: improve tool logging first. Do not weaken the gate by allowing an untraceable claim to masquerade as a fact; store it as an explicitly unverified hypothesis if the workflow needs it.
How do I roll out safer compaction?
- Inventory state: list every instruction, observation, decision, and work item your agent currently places in a summary.
- Add identifiers: give constraints, observations, decisions, and work items stable IDs and statuses.
- Instrument tools: emit call IDs, artifact or file revisions, timestamps, and retrievable raw outputs.
- Separate layers: keep immutable instructions, validated checkpoints, and the recent raw tail in different stores or sections.
- Choose a baseline strategy: use truncation or a sliding window as a hard backstop, then add tool-result reduction or summarization where semantic continuity requires it.
- Insert the provenance gate: validate every retained claim before publishing a checkpoint.
- Add action-time checks: re-read mutable state, verify permissions, and confirm destinations immediately before consequential actions.
- Test repeated resets: run long-lived tasks with changing files or records and force several compaction events.
- Track cost and quality together: monitor token use, summary latency, cache reuse, retries, blocked proposals, violations, and accepted outcomes.
- Review rejected entries: use diagnostics to improve source instrumentation and prompts, never to quietly reclassify unsupported claims as facts.
The resulting architecture treats compaction as a controlled state transition. The agent can forget redundant wording, but it cannot silently promote its own guess into history.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Frequently Asked Questions
Can a vector database solve context-compaction errors by itself?
No. Retrieval can bring back documents, but it does not prove that a retrieved statement was observed in the current environment or remains valid for the current revision. Store provenance and freshness metadata with each memory, then revalidate mutable facts before acting.
Should every tool output be copied into the next prompt?
No. Keep the raw output behind a durable handle and place only the fields needed for the next decision in the active context. The compact record should identify the source, scope, and timestamp so the full output can be fetched when necessary.
What happens if the summarizer and the source log disagree?
Treat the source log or a trusted, approved checkpoint as authoritative and mark the summary entry invalid. Preserve the disagreement for diagnosis; do not merge the two versions into a more confident sentence.
Is a larger context window enough to prevent folklore?
No. A larger window delays the boundary but does not remove interpretation, stale-state, or provenance failures. Long tasks still need typed checkpoints, source handles, and action-time validation when history is reduced or reconstructed.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.

