Skip to content

fix(web): Compact chip follows Claude's real prompt cache TTL - #17945

Merged
t3dotgg merged 1 commit into
mainfrom
fix/compact-chip-cache-ttl
Oct 11, 2026
Merged

t3dotgg merged 1 commit into
mainfrom
fix/compact-chip-cache-ttl

Conversation

@t3dotgg

@t3dotgg t3dotgg commented Oct 10, 2026

Copy link
Copy Markdown
Member

The Compact chip used a fixed 70 minute idle timer. That is right for 1h cache writes on a Claude subscription. But Claude Code writes 5 minute cache entries with an API key, Bedrock, or Vertex, and after a subscription goes over its limits. For those users the cache is cold long before the chip shows. A user also reported that the chip showed after only about 10 minutes, which was confusing.

Changes:

  • The Claude adapter now reads usage.cache_creation on each main-agent response and reports the TTL it wrote (1h or 5m) as an optional promptCacheTtlMs on the turn's token usage.
  • The chip shows when that TTL has passed. When no TTL is known (old turns, or a response with no cache writes), it uses the old 70 minute rule.
  • The web now picks the newest token usage by its timestamp. Before, it took the last turn in the array, and snapshots sort turns by provider thread id. So a thread with more than one provider thread (for example after a Codex to Claude handoff) could read an old turn's usage after a reload. That gave an old timestamp and a wrong token count to both the chip and the context meter. This is a likely cause of the early chip report, but I did not reproduce it.
  • The Claude user doc now says the chip follows the cache, not "more than an hour".

Data check: in my local Claude transcripts, 99.8% of cache-write tokens are 1h, so subscription users see the chip at 60 minutes, not 70.

🤖 Generated with Claude Code using Claude Opus 5.5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Oct 10, 2026
@juliusmarminge juliusmarminge added the macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews label Oct 10, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 5f98d60

Macroscope's review found this PR approvable — This is a focused correction that reports Claude's actual cache lifetime and uses it to time the existing Compact chip, with a backward-compatible optional field and targeted tests. The fallback behavior remains intact, and the change introduces no new workflow, infrastructure, or sensitive-data surface.

You can add or adjust custom eligibility rules. Learn more.

@github-actions

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 20.9 KiB 20.9 KiB 0 B (0.0%) 29.3 KiB ✅
Codex Live turn messages 2 2 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB 0 B (0.0%) 29.3 KiB ✅
Claude Live turn messages 2 2 0 (0.0%) 8 ✅

Baseline: 5f7294d · PR result: 5f98d60 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Team
  • Run ID: c06d917d-f32c-48bf-9a90-e9a68560a83e

📥 Commits

Reviewing files that changed from the base of the PR and between 5f7294d and 5f98d60.


📒 Files selected for processing (9)
  • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
  • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
  • apps/web/src/components/ChatView.tsx
  • apps/web/src/components/chat/ContextWindowMeter.logic.test.ts
  • apps/web/src/components/chat/ContextWindowMeter.logic.ts
  • apps/web/src/lib/contextWindow.test.ts
  • apps/web/src/lib/contextWindow.ts
  • docs/user/providers-claude.md
  • packages/contracts/src/orchestrationV2.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.



📝 Walkthrough

Walkthrough

Claude token usage now reports prompt-cache lifetime. The web client selects the newest provider-turn usage report and uses its lifetime to determine when to offer resume compaction. Claude provider documentation describes cache lifetimes by authentication source.

Changes

Prompt-cache lifetime and compaction

Layer / File(s) Summary
Report Claude prompt-cache lifetime
packages/contracts/src/orchestrationV2.ts, apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts, apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
The token-usage contract adds an optional prompt-cache lifetime. The Claude adapter reports 60 minutes when one-hour cache tokens are present, or 5 minutes when only five-minute cache tokens are present. Tests cover both values and the unset case.
Apply cache lifetime to compaction
apps/web/src/lib/contextWindow.ts, apps/web/src/lib/contextWindow.test.ts, apps/web/src/components/ChatView.tsx, apps/web/src/components/chat/ContextWindowMeter.logic.ts, apps/web/src/components/chat/ContextWindowMeter.logic.test.ts, docs/user/providers-claude.md
The web client selects provider-turn usage by newest updatedAt and supplies its prompt-cache lifetime to compaction timing. The timing uses the reported lifetime or a 70-minute fallback. Tests cover selection and the five-minute threshold. Documentation describes cache lifetimes by authentication source.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant ClaudeAdapterV2
  participant ProviderTurn
  participant ChatView
  participant shouldOfferResumeCompaction
  ClaudeAdapterV2->>ProviderTurn: Adds promptCacheTtlMs to token usage
  ChatView->>ChatView: Selects usage with the newest updatedAt
  ChatView->>shouldOfferResumeCompaction: Supplies promptCacheTtlMs
  shouldOfferResumeCompaction->>shouldOfferResumeCompaction: Compares elapsed time with reported TTL or fallback
Loading

Suggested reviewers: juliusmarminge


Merge Risk: ⚪ Minimal · up to 5f98d

No merge-blocking issue was identified; the Compact chip measures the reported cache lifetime from the matching usage timestamp.

Pre-merge checks | Passed 3 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check Warning The description clearly explains the problem and implementation, but it does not provide the required scope and approval information or focused verification results. It also omits the required before/… Add the triaged issue or explicit maintainer approval, or explain why this focused bug fix qualifies without one. Document the focused tests or manual checks with observed results, including anything not checked. Add before/after screenshot…
✅ Passed checks (3 passed)
Check name Status Explanation
Title check Passed The title is concise, specific, and accurately describes the main change: making the Compact chip follow Claude's prompt-cache TTL.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

Full details: Description check

Explanation

The description clearly explains the problem and implementation, but it does not provide the required scope and approval information or focused verification results. It also omits the required before/after UI evidence for this UI change.

Resolution

Add the triaged issue or explicit maintainer approval, or explain why this focused bug fix qualifies without one. Document the focused tests or manual checks with observed results, including anything not checked. Add before/after screenshots and a short recording if timing or interaction behavior requires it.


  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@t3dotgg
t3dotgg merged commit c727d12 into main Oct 11, 2026
33 checks passed
@t3dotgg
t3dotgg deleted the fix/compact-chip-cache-ttl branch October 11, 2026 01:07
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Oct 11, 2026
## What's Changed
* fix(pi): preserve tool images and structured results by @StiensWout in pingdotgg/t3code#17851
* fix(server): Claude 5 task lists reach the tasks drawer by @Mnigos in pingdotgg/t3code#14964
* fix(web): find bar and thread details panel stop covering each other by @MatthewFeroz in pingdotgg/t3code#17858
* fix(web): use server metadata for file chip icons by @Yash-Singh1 in pingdotgg/t3code#17923
* fix(desktop): copy images from HTML previews by @Bil0000 in pingdotgg/t3code#17555
* docs(pi): update installation and remote login guidance by @StiensWout in pingdotgg/t3code#17836
* fix(pi): preserve native abort outcomes by @StiensWout in pingdotgg/t3code#17853
* fix(pi): keep thinking defaults specific to each model by @StiensWout in pingdotgg/t3code#17835
* fix(pi): preserve shell command exit codes by @StiensWout in pingdotgg/t3code#17834
* fix(pi): expire and cancel extension approvals by @StiensWout in pingdotgg/t3code#17840
* feat(pi): include native sessions in usage reports by @StiensWout in pingdotgg/t3code#17848
* fix(server): route Copilot ACP subagent output into subagent threads by @maria-rcks in pingdotgg/t3code#17714
* fix(web): composer banner titles truncate beside their icon instead of wrapping by @maria-rcks in pingdotgg/t3code#17699
* fix(server): Muse turns no longer fail on Windows by @ntindle in pingdotgg/t3code#17163
* fix(pi): allow known read-only T3 tools without approval by @StiensWout in pingdotgg/t3code#17852
* fix: worktree threads keep their worktree when the agent starts, and messages sent during setup queue by @maria-rcks in pingdotgg/t3code#17654
* fix(server): keep Claude workflows alive while they report progress by @maria-rcks in pingdotgg/t3code#17715
* fix(web): media preview centers its content and pins the close button by @maria-rcks in pingdotgg/t3code#17951
* fix(server): threads without a project no longer need Git installed by @t3dotgg in pingdotgg/t3code#17959
* fix(web): toggling tools and thinking at the bottom keeps you at the bottom by @t3dotgg in pingdotgg/t3code#17954
* fix(web): Compact chip follows Claude's real prompt cache TTL by @t3dotgg in pingdotgg/t3code#17945
* fix(usage): bound OpenCode history reads to prevent backend OOM by @Yash-Singh1 in pingdotgg/t3code#17961
* refactor: format diff line counts through one shared helper by @maria-rcks in pingdotgg/t3code#17948
* fix: new projects start their first thread in the project folder, not a worktree by @t3dotgg in pingdotgg/t3code#17371

## New Contributors
* @ntindle made their first contribution in pingdotgg/t3code#17163

**Full Changelog**: pingdotgg/t3code@v0.0.46-nightly.20261010.2948...v0.0.46-nightly.20261011.2955

Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.46-nightly.20261011.2955
github-actions Bot added a commit to davidvanderklay/t3code-flake that referenced this pull request Oct 11, 2026
## What's Changed
* fix(pi): preserve tool images and structured results by @StiensWout in pingdotgg/t3code#17851
* fix(server): Claude 5 task lists reach the tasks drawer by @Mnigos in pingdotgg/t3code#14964
* fix(web): find bar and thread details panel stop covering each other by @MatthewFeroz in pingdotgg/t3code#17858
* fix(web): use server metadata for file chip icons by @Yash-Singh1 in pingdotgg/t3code#17923
* fix(desktop): copy images from HTML previews by @Bil0000 in pingdotgg/t3code#17555
* docs(pi): update installation and remote login guidance by @StiensWout in pingdotgg/t3code#17836
* fix(pi): preserve native abort outcomes by @StiensWout in pingdotgg/t3code#17853
* fix(pi): keep thinking defaults specific to each model by @StiensWout in pingdotgg/t3code#17835
* fix(pi): preserve shell command exit codes by @StiensWout in pingdotgg/t3code#17834
* fix(pi): expire and cancel extension approvals by @StiensWout in pingdotgg/t3code#17840
* feat(pi): include native sessions in usage reports by @StiensWout in pingdotgg/t3code#17848
* fix(server): route Copilot ACP subagent output into subagent threads by @maria-rcks in pingdotgg/t3code#17714
* fix(web): composer banner titles truncate beside their icon instead of wrapping by @maria-rcks in pingdotgg/t3code#17699
* fix(server): Muse turns no longer fail on Windows by @ntindle in pingdotgg/t3code#17163
* fix(pi): allow known read-only T3 tools without approval by @StiensWout in pingdotgg/t3code#17852
* fix: worktree threads keep their worktree when the agent starts, and messages sent during setup queue by @maria-rcks in pingdotgg/t3code#17654
* fix(server): keep Claude workflows alive while they report progress by @maria-rcks in pingdotgg/t3code#17715
* fix(web): media preview centers its content and pins the close button by @maria-rcks in pingdotgg/t3code#17951
* fix(server): threads without a project no longer need Git installed by @t3dotgg in pingdotgg/t3code#17959
* fix(web): toggling tools and thinking at the bottom keeps you at the bottom by @t3dotgg in pingdotgg/t3code#17954
* fix(web): Compact chip follows Claude's real prompt cache TTL by @t3dotgg in pingdotgg/t3code#17945
* fix(usage): bound OpenCode history reads to prevent backend OOM by @Yash-Singh1 in pingdotgg/t3code#17961
* refactor: format diff line counts through one shared helper by @maria-rcks in pingdotgg/t3code#17948
* fix: new projects start their first thread in the project folder, not a worktree by @t3dotgg in pingdotgg/t3code#17371

## New Contributors
* @ntindle made their first contribution in pingdotgg/t3code#17163

**Full Changelog**: pingdotgg/t3code@v0.0.46-nightly.20261010.2948...v0.0.46-nightly.20261011.2955

Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.46-nightly.20261011.2955
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants