Skip to content

Remove unused items tracking from Claude adapter state - #13718

Merged
t3dotgg merged 3 commits into
mainfrom
claude/perf-report-triage-qbbrr7
Sep 26, 2026
Merged

t3dotgg merged 3 commits into
mainfrom
claude/perf-report-triage-qbbrr7

Conversation

@t3dotgg

@t3dotgg t3dotgg commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

What Changed

Removed the items array from ClaudeTurnState and ClaudeSessionContext.turns entries, along with all code that populated and copied this data structure. The items array was being tracked but never read or used anywhere in the codebase.

Why

This change eliminates unnecessary memory overhead in long-lived sessions. The items array was accumulating messages throughout a session's lifetime but served no functional purpose. By removing it:

  • Memory efficiency: Long-lived sessions no longer retain every message ever produced
  • Simplified state management: Reduces complexity by removing unused state tracking
  • Clearer intent: The turns array now only tracks turn IDs needed for rollback counting, as documented in the updated comment

The rollback mechanism relies on Claude's own history (via the SDK), not on locally stored messages, so this data was redundant.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • No UI changes

https://claude.ai/code/session_01Vkxwfu3bhLfZE4x2Fx8hra

Summary by CodeRabbit

  • Bug Fixes
    • Thread snapshots now show completed Claude turns with their turn IDs and empty message lists. Messages collected during a turn are no longer included in the snapshot after it completes, while the completed turn’s ID remains available when the thread is read.

The Claude adapter copied each turn's SDK user and assistant messages into
context.turns and kept them until the session stopped. Nothing reads them:
rollback works from Claude's on-disk history and turnStartMessageIds, and
no production caller uses readThread's items. Keep only turn ids.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vkxwfu3bhLfZE4x2Fx8hra
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Sep 25, 2026
@github-actions

github-actions Bot commented Sep 25, 2026 •

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 13.5 KiB 13.5 KiB +10 B (+0.1%) 15.1 KiB ✅
Codex Thread snapshot wire 7.1 KiB 7.1 KiB −2 B (−0.0%) 7.3 KiB ✅
Codex Live turn WebSocket wire 6.4 KiB 6.5 KiB +12 B (+0.2%) 7.8 KiB ✅
Codex Live turn WebSocket decoded 56.2 KiB 56.3 KiB +44 B (+0.1%) 66.4 KiB ✅
Codex Live turn messages 9 10 +1 (+11.1%) 21 ✅
Claude Total thread wire 13.5 KiB 13.5 KiB −10 B (−0.1%) 15.1 KiB ✅
Claude Thread snapshot wire 7.1 KiB 7.1 KiB −12 B (−0.2%) 7.3 KiB ✅
Claude Live turn WebSocket wire 6.4 KiB 6.4 KiB +2 B (+0.0%) 7.8 KiB ✅
Claude Live turn WebSocket decoded 57.0 KiB 57.0 KiB 0 B (0.0%) 66.4 KiB ✅
Claude Live turn messages 9 9 0 (0.0%) 21 ✅

Baseline: ed809f7 · PR result: c290b0e · 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: 114.0 KiB
  • Claude decoded thread snapshot: 114.7 KiB

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

@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: ce891c6f-df48-48e9-90e1-9d1aae6a154c

📥 Commits

Reviewing files that changed from the base of the PR and between fafbc6f and c290b0e.

📒 Files selected for processing (1)
  • apps/server/src/provider/Layers/ClaudeAdapter.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/server/src/provider/Layers/ClaudeAdapter.ts

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


📝 Walkthrough

Walkthrough

ClaudeAdapter no longer retains SDK message objects in active or completed turn state. Completed turns retain their IDs, and snapshotThread returns completed turns with empty items arrays.

Changes

Claude turn state

Layer / File(s) Summary
Turn message retention and snapshots
apps/server/src/provider/Layers/ClaudeAdapter.ts, apps/server/src/provider/Layers/ClaudeAdapter.test.ts
Turn initialization and message handlers no longer collect SDK messages. Completed-turn history stores turn IDs, and thread snapshots return empty items arrays. The test verifies the completed turn ID and empty item list.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to c290b

The change reduces retained message data without an identified break in thread reads or rollback. No actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: removing unused items tracking from the Claude adapter state.
Description check ✅ Passed The description includes the required What Changed and Why sections, explains the memory and state-management impact, and provides a checklist. The UI Changes section is addressed as not applicable be…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
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.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

Comment thread apps/server/src/provider/Layers/ClaudeAdapter.ts
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vkxwfu3bhLfZE4x2Fx8hra
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Sep 25, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at c290b0e

Macroscope's review found this PR approvable — This focused refactor removes unused Claude SDK message retention, reducing memory use while preserving turn IDs and rollback behavior. The added test verifies that completed-turn snapshots retain IDs with empty item lists.

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

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vkxwfu3bhLfZE4x2Fx8hra
@macroscopeapp
macroscopeapp Bot dismissed their stale review September 25, 2026 23:49

Dismissing prior approval to re-evaluate c290b0e

@t3dotgg
t3dotgg merged commit 5660ab5 into main Sep 26, 2026
23 of 24 checks passed
@t3dotgg
t3dotgg deleted the claude/perf-report-triage-qbbrr7 branch September 26, 2026 02:12
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Sep 26, 2026
## What's Changed
* feat(desktop): honor the standard OTLP variables in the main process and WSL backends by @yordis in pingdotgg/t3code#13641
* fix(web): restore compact provider instance badges by @t3-code[bot] in pingdotgg/t3code#13700
* perf(mobile): lighter Home rows away from the viewport by @AKolenda in pingdotgg/t3code#13702
* fix(usage): price Cursor cache savings by base model by @Yash-Singh1 in pingdotgg/t3code#13731
* perf(mobile): render Home rows further ahead while scrolling by @AKolenda in pingdotgg/t3code#13705
* refactor(observability): name each service after its application by @yordis in pingdotgg/t3code#13699
* perf(server): stop remapping every thread on each thread event by @t3dotgg in pingdotgg/t3code#13720
* Remove unused items tracking from Claude adapter state by @t3dotgg in pingdotgg/t3code#13718
* feat(observability): name the command on subprocess spans by @t3dotgg in pingdotgg/t3code#13701
* fix(cli): t3 triage points agents at log files that exist by @t3dotgg in pingdotgg/t3code#13685
* fix(server): the SQLite WAL file shrinks back after large writes by @t3dotgg in pingdotgg/t3code#13684
* feat(cli): summarize the server trace file from the command line by @t3dotgg in pingdotgg/t3code#13698
* perf(server): pull request sync reads only threads with linked pull requests by @t3dotgg in pingdotgg/t3code#13704

## New Contributors
* @AKolenda made their first contribution in pingdotgg/t3code#13702

**Full Changelog**: pingdotgg/t3code@v0.0.43-nightly.20260925.2269...v0.0.43-nightly.20260926.2282

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

Labels

size:S 10-29 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