Skip to content

Compact-first chip on cold, large Claude threads (#1531) - #1543

Merged
currentbits merged 1 commit into
mainfrom
coder/1531-compact-on-send-chip-cae77f
Oct 9, 2026
Merged

currentbits merged 1 commit into
mainfrom
coder/1531-compact-on-send-chip-cae77f

Conversation

@currentbits

Copy link
Copy Markdown
Owner

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.

  • The decision is a pure helper, coldCompactTokens in src/contextRing.ts. It uses usage.contextTokens, which already includes cache_read and cache_creation.
  • Limits:
    • "Idle" is measured from thread.updatedAt, so a non-run change such as a rename restarts the hour.
    • The check runs on render, so a thread left open shows the strip on its next re-render rather than the minute it goes cold.
    • The 50k threshold is a constant.

Tests are in test/contextRing.test.ts and test/composerSlashActions.test.tsx.

🤖 Generated with Claude Code

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>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T12:14:47.452547Z 9ff32b3 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/contextRing.ts
Comment on lines +75 to +76
/** Anthropic's extended prompt-cache TTL; past it the next send re-reads everything. */
export const CLAUDE_CACHE_TTL_MS = 60 * 60 * 1000;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@currentbits
currentbits merged commit 1ca1975 into main Oct 9, 2026
6 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