Replace idle TTL folds with an opt-in Anthropic cache prompt transform - #1161
Merged
TheGreatAxios merged 9 commits intoSep 25, 2026
Conversation
Guessed windows for other providers fold a cache that is still warm. Only Anthropic publishes a 5-minute expiry this client actually uses.
TheGreatAxios
force-pushed
the
cl-8914-limit-idle-recompress-to-anthropics-published-5-minute-cache
branch
from
September 23, 2026 23:56
6d61493 to
b692de0
Compare
A resumed process only knew the cache write time in memory, so the first request rewrote the full prefix. Persist the Anthropic stamp and fold through the existing compactor before that infer.
Runners persist the catalog id, which is not the messages adapter name. Requiring that id to match the protocol dropped an expired stamp, so the next request sent the untrimmed history.
Cache expiry no longer compacts stored turns. The prompt transform runs only when anthropicCachePrompt is set.
The settings fixture covers anthropicCachePrompt. Unused governor clocks are gone.
The provider table is gone, so the sentence that explained its ollama row is gone too.
## Summary The TTL fold path is gone, so the governor's outstandingToolCalls tracking was write-only and the stall-ping test merged from main still expected a cache-ttl-recompress compact. Rewrite the provider-aware describe block to pin the new contract — idle re-entry never folds, whatever the provider window. ## Verification - bun test src/agent/compaction.test.ts src/subagent/nudge-director.test.ts (117 pass) - bun run check (the one local failure is a /tmp symlink artifact of the worktree path; the same test passes on a real checkout) Refs CL-8914
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cache expiry no longer compacts.
turns.jsonlkeeps its history; instead a pre-inference context transform stubs old tool-result bodies on the outgoing prompt when the last Anthropic-protocol cache write is over 5 minutes old. Other providers never fire — the guessed TTL table is gone. Gated by the newanthropicCachePromptsetting, which defaults off.createAnthropicCachePromptTransformstubs consumed tool-result bodies before the newest assistant text, on the outgoing request only.inference.doneand persisted on the run record, so a resumed session keeps the warm-cache fast path instead of stubbing into it.cache-ttl-recompressfold path and theoutstandingToolCallstracking that existed only to guard it.Verification
Fixes CL-8914