The warning arrived in an unusually concrete form. Anthropic’s April 23 postmortem described a Claude Code bug in which a cache-maintenance change removed older reasoning from every later turn after a session had been idle for more than an hour. The intended behavior was a one-time cleanup of thinking history after a cache eviction. Instead, the system kept applying the cleanup, leaving the agent increasingly unable to remember why it had made earlier edits or tool calls. Anthropic said the result was forgetfulness, repetition, odd tool choices, cache misses and faster usage-limit depletion.

That incident changes the executive question. Prompt caching is usually discussed as a unit-economics lever: reuse a large prefix, pay less, respond faster. But a production agent can begin behaving as if the cached prompt is part of its durable state. If a changed prefix or overly aggressive compaction alters the assembled context, or if application logic wrongly changes context in response to cache expiry or a routing miss, the agent may make a different decision while its application still considers the session continuous.

For companies selling agents into coding, operations, finance or regulated workflows, that is not merely an infrastructure bug. It is a trust and retention risk. Customers forgive a slow task more readily than an agent that resumes a task with misplaced confidence and a missing rationale.

The cache is not the session

The foundational design rule is simple: a prompt cache is not a database, a memory system or an audit log. It is an opportunistic reuse mechanism for computational state associated with a prompt prefix.

Modern agent architecture makes that distinction more important. Anthropic’s managed-agent architecture separates an agent into a durable, append-only session log; a harness that selects context, calls the model and routes tools; and a sandbox that executes actions. The company’s central point is that the session is not the model’s context window. The session remains recoverable outside the window, while the harness decides what material to reconstruct for each inference.

EVENTS, ARTIFACTS, APPROVALSMODEL RESPONSE OR TOOL DECISIONEVENTS, ARTIFACTSASSEMBLED CONTEXTMODEL RESPONSE OR TOOLNEW EVENTSTABLE PREFIXDURABLESESSIONLOGrecoverableappend-onlyhistoryCONTEXT-SELECTIONHARNESSselectscontextandMODELWINDOWtransientinferencecontextSTABLEPROMPTPREFIXreusablerequestprefixCACHELOOKUPopportunisticreuse ofcomputational
Figure 1 - How a durable agent session is reconstructed into model context while prompt caching remains an optimization

This separation creates a more defensible operating model. The session log records what actually happened: user requests, tool calls, tool results, approvals, policy versions, files changed and checkpoints. The harness is a deterministic or at least inspectable reconstruction layer. The prompt cache accelerates the stable portion of the resulting request. It should not determine whether the agent can explain, reproduce or safely continue its work.

A naive transcript replay system reverses those priorities. It treats the entire past conversation as both history and context. That works for short chats. It degrades badly when agents run for hours, call tools repeatedly and accumulate huge outputs. The full transcript becomes too large, too noisy and too expensive. Engineers then trim it, summarize it or depend on a cached prefix to make replay tolerable. At that point, a transient optimization begins to carry application semantics.

The better architecture is durable event sourcing plus selective context assembly. Preserve the full record. Retrieve the relevant parts. Summarize explicitly and version the summary. Then construct a cache-friendly request from stable, validated components.

Why prefix matching changes agent behavior

Prompt caching works through prefix reuse, not a vague similarity judgment. OpenAI’s prompt-caching documentation says that the system seeks the longest available matching cached prefix, working backward through eligible cache breakpoints. For GPT-5.6 and later, the minimum cacheable prompt length is 1,024 tokens. The docs also distinguish writes from reads: a default 30-minute cache write costs 1.25 times ordinary uncached input, while a cache read generally costs 0.1 times the ordinary input rate, with some models priced at 0.05 times.

MATCHING PREFIXMATCHING PREFIXNEW BLOCKSNEW BLOCKSREQUEST ASystempolicy v42REQUEST BSystempolicy v42MATCHINGCACHEDPREFIXshared bybothrequestsRECENTEVENTS Anew; maycache laterRECENTEVENTS Bnew; maycache laterThe cache breakpoint ends this reusable prefix; later blocks are not reused through it, but may be cached s...
Figure 2 - how two requests reuse the longest matching cached prefix while their later blocks differ

The economic logic is powerful. A well-designed agent can put durable system instructions, static tool schemas, stable workspace configuration and other broadly shared material early in the request. It can append variable user requests, newly retrieved evidence and recent events later. The stable prefix gets reused, while only the changing suffix needs fresh processing.

The chart clarifies why product teams chase hit rates. With ten identical full-prefix requests, OpenAI’s example puts one default-lifetime write and nine reads at 2.15 times the ordinary input cost, compared with 10 times the cost without caching. That spread can improve gross margins and make an agent feel dramatically faster.

But prefix sensitivity means seemingly innocent changes can shatter reuse. Reordering tool definitions, inserting a timestamp into a developer message, changing a policy string, adding an experiment tag, rotating a workspace setting or moving instructions from one message section to another may invalidate a substantial cached prefix. The response can still be correct, but costs and latency jump suddenly. Worse, if the application used the cache as a substitute for state reconstruction, behavior can change too.

Compaction must preserve recoverability

Long-running agents cannot keep every token in the active context window. Anthropic’s context-engineering guidance describes context engineering as ongoing curation of system instructions, tools, external information and message history. It recommends compaction, structured note-taking and retrieval strategies for work that exceeds the model window. Anthropic describes compaction as summarizing a near-limit conversation and restarting with that high-fidelity summary, while warning that overly aggressive compression can discard details that later become critical.

The reliability implication is that compaction is a transformation, not deletion. A summary can be a useful context artifact, but it must never be the only surviving copy of the events it represents. The original tool results, decisions and approval records should remain addressable in the durable log. A resumed agent needs the ability to inspect source events when a summary lacks the needed detail.

SOURCE EVENTS AND DURABLE RECORDSRETRIEVE EXACT PRIOR EVENTS WHEN NEEDEDSOURCE EVENTS AND DURABLECOMPACTED CONTEXTRETRIEVE EXACT PRIORRAWEVENTLOGUserrequest ·ToolVERSIONEDCOMPACTIONSUMMARYHigh-fidelitycontextartifactACTIVEMODELCONTEXTResumedworkingcontextCompaction transforms context; it does not delete source events
Figure 3 - How an agent resumes from a compacted summary while retaining access to the exact events behind it

This is also where reasoning state needs careful treatment. The postmortem shows that older thinking can help an agent understand the rationale behind prior action. But teams should not assume every intermediate reasoning trace belongs in every later prompt. The protocol should instead distinguish among durable decision records, task plans, tool evidence, approvals, compacted summaries and any provider-specific reasoning artifacts. Each category needs an explicit retention and retrieval rule.

That avoids two common errors. The first is retaining everything, which creates context pollution and makes relevance harder. The second is treating internal reasoning history as disposable cache material even when the agent’s future action depends on the rationale it contains.

Permission changes are an invalidation event

The most dangerous cache bug is not necessarily a miss. It is a hit on context that should no longer be valid.

Consider an agent with permission to modify a production repository, query a customer dataset or send emails on behalf of a user. If its stable prefix includes authorization assumptions, tool descriptions or workspace identity, a permission revocation must cause a new policy evaluation and a fresh context assembly. Reusing an old prefix that still implies broader authority turns performance optimization into an access-control failure.

✕ NEVER AUTHORIZE FROM CACHED CONTEXT ALONEPERMISSION STATENEW POLICY VERSIONINVALIDATED CONTEXTFRESH PROMPT CONTEXT✕ NEVER AUTHORIZEPERMISSIONOR POLICYCHANGESINCREMENTPOLICYVERSIONINVALIDATEAFFECTEDCONTEXTREBUILDPROMPTPREFIXAUTHORIZETOOL CALLOLD CACHEDPREFIXstaleauthorizationcontext
Figure 4 - How policy changes force fresh context assembly before a tool call

The design principle is to keep authorization outside the model’s remembered narrative. The harness should check permissions at tool-call time against the current policy state. Cache keys and context manifests should include policy version, tool-schema version, workspace identity and relevant data-scope version. A cache hit can reuse computation, but it cannot be proof that a previously allowed action remains allowed.

This approach also makes incidents diagnosable. When an agent produces an unexpected result after resuming, operators should be able to answer: Which session events were selected? Which summary version was used? Which policy version governed the tool call? How many tokens were cache reads, cache writes and uncached input? Was the request routed to a machine that held the prefix?

OpenAI recommends tracking cached tokens, cache-write tokens, input-token counts, latency and realized cost, then calculating token cache-hit rate as cached tokens divided by total input tokens. Its documentation also notes that a minimum cache lifetime does not guarantee every request will reuse stored key-value tensors or reduce latency.

Build a cache-aware agent protocol

A robust protocol begins with a context manifest for every model call. That manifest should identify the session-log range, retrieved documents, compaction-summary identifiers, system-policy version, tool-schema version, authorization scope, cache breakpoint layout and expected cache key. Store it with the response and tool events.

Next, design explicit invalidation classes. Security policy and permissions should invalidate immediately. Tool schema changes should invalidate the affected prefix. New user instructions may alter only the suffix. A changed retrieval result should refresh the evidence block without destabilizing unrelated static material. Cache expiration should trigger reconstruction from the durable log, not a degraded fallback assembled from whatever happened to remain in memory.

Test these conditions as product behavior, not only as API behavior:

  1. Resume after cache eviction and compare the agent’s plan, retrieved facts and tool permissions with a clean reconstruction.
  2. Change a system policy mid-session and verify that no old prefix authorizes a now-prohibited action.
  3. Force a cache miss and measure latency, input cost and task quality separately.
  4. Run compaction before and after an important decision, then verify the agent can retrieve the source event.
  5. Replay the same event log through a newly deployed harness version and record any context-manifest differences.

The research community has begun treating these problems as integration defects rather than edge cases. Ying Zhang and colleagues’ study examined 120 prompt-caching-related pull requests across 10 open-source agent systems and argued that many mis-integrations fail silently, appearing as higher cost or latency rather than runtime errors. Their CacheLint prototype found 32 mis-integrations across 571 agent projects, according to the paper.

There is a second concern: Chenchen Gu and co-authors warned that cache-driven timing differences can create side channels when cache state is shared across users. Their paper reported evidence of global cache sharing across users in seven API providers and argued that caching-policy transparency matters because response timing can reveal information about other users’ prompts.

Only one side was found in the supplied reception material: these researchers are critical of treating prompt caching as transparent plumbing. No supplied source made the opposing case that cache integration can safely remain invisible to agent developers.

That absence is telling. The business opportunity is still real. Caching can widen margins, lower latency and make sophisticated agents economical at scale. But the companies that capture the durable advantage will be those that treat cache hits as a performance outcome, not a state guarantee. In the agent market, fast is valuable. Recoverable, auditable and correct is the moat.

#Anthropic#Claude Code#OpenAI#GPT-5.6#Ying Zhang#Chenchen Gu#CacheLint

Rebeca Smith is not a person. No notebook, no deadlines, no face behind the name — just a byline this newsroom publishes under. Here is the production line underneath it, because a name beside a portrait reads like a journalist, and this one is not one.

The models. Writing: gpt-5.6-luna and qwen3-max. Out on the live web: gpt-5.6-luna and gpt-5.6-terra. Pictures: gpt-image-2.6-flare and gpt-image-2.6-sunburst. Swap one in the newsroom and this line swaps with it — it is read off the machines, not typed here.

How a story is made

  • Research. The searching model reads around the story, pointed at primary sources — the filing, the post, the repository — rather than at somebody else's write-up of them.
  • Writing. The writing model drafts it against what was found, at Rebeca Smith's usual length and in Rebeca Smith's usual register.
  • The loop. A reviewer reads the draft and sends it back with notes. Then reads it again. A piece can go round several times before it leaves the building.
  • Enrichment. A quotation has to appear word for word on the page it is taken from. A chart may only use figures that appear in the source it cites. Whatever fails is dropped, and the reason is kept.
  • Fact check. A last pass hunts for claims the article makes and its sources do not.
  • A human stop. Sensitive subjects are held for a person to read before publication, and a person can kill any of it at any point.

If that sounds less like a newsroom and more like a factory: quite. It is called Press Factory.

This article was generated using AI and published automatically without human pre-publication review.

How this article was made

The article was produced by the Grandmonts Media News Engine using automated research, drafting and verification workflows. No human editor reviewed the article before publication. Grandmonts Media remains responsible for the published content. Errors can be reported at office@grandmonts.cz.