Skip to content

Replace idle TTL folds with an opt-in Anthropic cache prompt transform - #1161

Merged
TheGreatAxios merged 9 commits into
mainfrom
cl-8914-limit-idle-recompress-to-anthropics-published-5-minute-cache
Sep 25, 2026
Merged

TheGreatAxios merged 9 commits into
mainfrom
cl-8914-limit-idle-recompress-to-anthropics-published-5-minute-cache

Conversation

@TheGreatAxios

@TheGreatAxios TheGreatAxios commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Cache expiry no longer compacts. turns.jsonl keeps 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 new anthropicCachePrompt setting, which defaults off.

  • createAnthropicCachePromptTransform stubs consumed tool-result bodies before the newest assistant text, on the outgoing request only.
  • The last Anthropic cache write is stamped at inference.done and persisted on the run record, so a resumed session keeps the warm-cache fast path instead of stubbing into it.
  • Governor loses the cache-ttl-recompress fold path and the outstandingToolCalls tracking that existed only to guard it.

Verification

  • bun test src/provider/cache-ttl.test.ts src/agent/compaction.test.ts src/subagent/nudge-director.test.ts src/session/anthropic-cache-prompt.test.ts src/session/cache-ttl-resume.test.ts
  • bun run check

Fixes CL-8914

@linear-code

linear-code Bot commented Sep 23, 2026

Copy link
Copy Markdown

CL-8914

Guessed windows for other providers fold a cache that is still warm. Only Anthropic publishes a 5-minute expiry this client actually uses.
@TheGreatAxios
TheGreatAxios force-pushed the cl-8914-limit-idle-recompress-to-anthropics-published-5-minute-cache branch from 6d61493 to b692de0 Compare September 23, 2026 23:56
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
@TheGreatAxios TheGreatAxios changed the title Limit idle recompress to Anthropic's 5-minute cache Replace idle TTL folds with an opt-in Anthropic cache prompt transform Sep 25, 2026
@TheGreatAxios
TheGreatAxios merged commit 15aea04 into main Sep 25, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant