Repository navigation
Compact-first chip on cold, large Claude threads (#1531) - #1543
Conversation
Past Anthropic's 1 h prompt-cache TTL the next send re-reads the whole context at full price. Claude threads idle that long with >= 50k context tokens (usage.contextTokens, which already sums cache read + creation) get a "Compact first (≈N tokens)" action on the composer status tab that runs the existing native /compact. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9ff32b3ff0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| /** Anthropic's extended prompt-cache TTL; past it the next send re-reads everything. */ | ||
| export const CLAUDE_CACHE_TTL_MS = 60 * 60 * 1000; |
There was a problem hiding this comment.
Derive the timeout from the actual cache tier
For Claude sessions whose usage reports ephemeral_5m_input_tokens, this hard-coded hour suppresses the warning for 55 minutes after the cache has already expired. Five minutes is the platform default and one hour is an optional extended tier (Anthropic prompt-caching documentation); the runner currently discards the usage.cache_creation tier breakdown when producing SessionUsage, so these sessions are indistinguishable here. Preserve the observed tier/TTL and use it in this calculation rather than assuming every Claude session receives the extended cache.
Useful? React with 👍 / 👎.
Part of #1531.
A Claude thread that has been idle for more than an hour, past the prompt-cache TTL, with at least 50k context tokens now shows a composer strip: "Prompt cache expired; the next send re-reads the whole context." It has a Compact first (≈N tokens) button that runs the existing native compact (
handleCompact). The strip only appears when native compact is available and the thread isn't archived.coldCompactTokensinsrc/contextRing.ts. It usesusage.contextTokens, which already includes cache_read and cache_creation.thread.updatedAt, so a non-run change such as a rename restarts the hour.Tests are in
test/contextRing.test.tsandtest/composerSlashActions.test.tsx.🤖 Generated with Claude Code