Context grows as an agent accumulates messages, tool results and earlier decisions. Keeping everything is simple until each new step carries a large amount of material that no longer helps. The goal is a useful working context, rather than the shortest possible prompt.
Classify information before removing it
Separate durable instructions, current task state, recent observations and historical evidence. Permissions and safety constraints belong in the durable group. A current account identifier or an uncertain action outcome may be essential even when it looks like a small detail.
Large completed tool outputs are candidates for summarization or later retrieval. A navigation menu from ten steps ago is often less useful than the result of the last action. Treat that as a hypothesis to test on your workload, not a universal deletion rule.
Summarize state, not confidence
A useful checkpoint names the objective, completed steps, remaining work, active account and known uncertainties. Preserve the difference between an attempted action and a confirmed result. A summary that turns “submitted, outcome unknown” into “completed” can trigger a duplicate action later.
Retain references to evidence that can be fetched again. If the underlying page can change, mark which facts need a fresh check instead of treating an old summary as live data.
Measure the transition cost
Claude documents context editing as a way to manage conversation content. Availability and configuration vary, so consult the documentation for the model and API in use. Application-managed summaries are a separate design choice and need their own validation.
Compaction or editing may change cache reuse. Measure the cost of producing a summary, the next request after the transition and subsequent requests. A lower cache-hit rate can coexist with a lower bill when the new context is much smaller.
Evaluate difficult recoveries
Test a resumed task after a login change, a stale page, a failed tool call and an interrupted submission. Check whether the agent remembers what it is allowed to do and what still needs confirmation.
Set a context budget, but pair it with a correctness gate. If a compacted agent loses a critical constraint, saving tokens has made the system worse. Keep the original trace in appropriately protected storage when you need it for evaluation, rather than in every new model request.
A checkpoint you can test
A checkpoint might read: “Goal: download this account’s monthly report. Confirmed: correct account and report month selected. Attempted: download click. Unknown: whether a file was created. Next: inspect downloads before clicking again. Authority: read-only task; do not change account settings.” Use synthetic data to test this pattern. Keep live account identifiers private and preserve evidence references outside the model’s repeated working context.
Sign in ↗