Skip to content

fix(server): forks of compacted Claude threads keep their compaction - #27563

Closed
VendettaGhub wants to merge 2 commits into
pingdotgg:mainfrom
VendettaGhub:fix/claude-fork-compaction-sdk
Closed

VendettaGhub wants to merge 2 commits into
pingdotgg:mainfrom
VendettaGhub:fix/claude-fork-compaction-sdk

Conversation

@VendettaGhub

Copy link
Copy Markdown
Contributor

Problem

Forking a Claude thread that has been compacted makes the fork load the thread's full pre-compaction history. The fork's first message then sets off a chain of auto-compactions before Claude answers. In my case that was four compactions and about five minutes: 559K → 1.60M → 1.23M → 638K → 36.2K. Details and the investigation are in #27552.

Cause: before 0.3.284, forkSession in @anthropic-ai/claude-agent-sdk gives copied messages new UUIDs but leaves the UUIDs inside each compaction boundary (compactMetadata.preservedSegment and preservedMessages) unchanged. In the fork they point at messages that don't exist, so Claude can't rebuild the compacted conversation. The server still pinned 0.3.276.

Change

Raise the Agent SDK to ^0.3.312 and update the minimumReleaseAgeExclude entry and lockfile to match. 0.3.284 is the first release that remaps those references (bisected: 0.3.276–0.3.283 leave them dangling, 0.3.284 and later remap them). 0.3.312 is the newest version the release-age gate accepts today, and the lockfile resolves to it.

The existing fork test in ClaudeAgentSdkQueryRunner.test.ts now writes a compaction boundary with preserved messages into its source transcript. It checks that every reference in the fork points at the forked copy of the right message.

Scope and approval

Bug report: #27552. A very small fix of an obvious bug in an existing capability. Only the dependency version and one existing test change.

Verification

  • The extended fork test fails on 0.3.276 (expected { …(3) } to deeply equal { …(3) }) and passes on 0.3.312.
  • vp run --filter t3 typecheck passes for the server on 0.3.312.
  • ClaudeAgentSdkQueryRunner.test.ts: 7 passed, 3 skipped (POSIX-only) on Windows.
  • ClaudeAdapterV2.test.ts has 13 failures on Windows. Unmodified main with 0.3.276 has the same 13, from Windows path escaping in the attachment tests and the win32 settings directory.
  • Outside T3, same small session with three /compacts, then fork and resume: the first turn took 77,951 input tokens with 0.3.276 and 47,267 with 0.3.314.

Not checked: a live fork from a running T3 build with this change. CI runs the Linux suites.

Made with Claude Opus 5.5 in Claude Code (T3 Code), reviewed by GPT-6.1 Terra and DeepSeek V4.1 Flash.

Copilot AI balanced review requested due to automatic review settings October 30, 2026 11:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Oct 30, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 453f090

Macroscope's review found this PR approvable — The assessed change moves the SDK's release-age exemption to version 0.3.312 while keeping it restricted to one exact version. It does not directly change runtime defaults or disable static-analysis diagnostics.

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

@coderabbitai

coderabbitai Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 32ecd71 and 453f090.

Files ignored due to path filters: 1
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing: 3
  • apps/server/package.json
  • apps/server/src/orchestration-v2/Adapters/ClaudeAgentSdkQueryRunner.test.ts
  • pnpm-workspace.yaml

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

The pull request updates the Claude Agent SDK dependency and adds fork-test coverage for compact-boundary UUID references in copied transcripts.

Changes: Claude fork transcript

Layer / File(s) Summary
SDK update and fork transcript coverage
apps/server/package.json, pnpm-workspace.yaml, apps/server/src/orchestration-v2/Adapters/ClaudeAgentSdkQueryRunner.test.ts
The SDK version and release-age exclusion move from 0.3.276 to 0.3.312. The fork test adds compact-boundary fixture data and checks that preserved-message references use UUIDs from the copied transcript.

Priority: Normal

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

Change: Bug fix

Possibly related issues

  • Issue 27552 describes the compact-boundary UUID defect in Claude forks. This pull request upgrades the SDK and adds regression coverage for remapped preserved-segment references.

Suggested reviewers: juliusmarminge

Merge Risk: Minimal · up to 453f0

No merge-blocking risk was identified in the SDK update or fork regression test.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main fix: preserving compaction data when forking compacted Claude threads.
Description check Passed The description includes all required sections. It explains the problem, cause, fix, scope, linked issue, verification results, known failures, and the untested live-fork scenario.
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 unit tests (beta)
  • 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.

@maria-rcks

maria-rcks commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Note

Written by gpt-6.1-sol on behalf of Maria

Verified in a real dev environment

verified unchanged head 453f090addb078af90378e9b480e0efedd578395 on linux, using separate installs and one dev server at a time. chrome/playwright drove project creation, real provider turns, and the response fork button. no mocks or seeded transcripts.

  • on github/main (ce48e45900, sdk 0.3.276), created a real claude haiku 5.5 conversation, compacted, supplied 115k characters of repository source through t3 thread send against the running server, then compacted again. the second boundary had both preserved-reference fields. after a web-ui fork and real reply, 8/8 copied references were dangling.
  • on this pr (sdk 0.3.312), repeated the same sequence and source text. compaction reduced 73.5k to 3.74k tokens. the web-ui fork rewrote 8/8 references to the correct copied message contents, with 0 dangling references. its first real reply recalled violet-otter-27563, with no additional auto-compaction.
  • nearby behavior passed: fork before compaction recalled the secret, the original source continued after forking, and real codex gpt-6.1-sol turns created/read the real repository file on main/pr.
  • blacksmith: all 10 query-runner tests passed; vp run check:changed 32ecd71726fee16f335484c1f95cbce126d461f6 passed format, lint, knip, patch/graphql validation, affected typechecks and 11 tests. the explicit base was needed because the remote worker has shallow history. github reports 29 successful checks.

live transcript inspection:

main sdk 0.3.276: 8 preserved references; 8 dangling
pr sdk 0.3.312: 8 preserved references; 0 dangling
8/8 references remapped to the same message contents; fork recalled secret; 0 auto-compactions
fork before compaction: recalled secret; 0 compaction boundaries
source continuation: source still works; violet-otter-27563

main: compacted claude fork and live reply

pr: compacted claude fork and live reply

pr: fork a compacted claude conversation and recall context

Not verified

native desktop/mobile shells, windows/macOS, remote relay/tunnel, and the original multi-day oversized-session compaction cascade. main reproduced the dangling-reference defect, but this smaller real conversation still answered without an auto-compaction cascade. no latency improvement claim. claude used the real local provider proxy and installed CLI 2.1.316.

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #27577, which fixes #27552 by upgrading the Claude Agent SDK to 0.3.284 and adds a regression test for compaction references.

This PR uses a newer SDK and checks the exact UUID-to-message mapping, but it doesn't provide a separate runtime fix. I won't pursue the additional test coverage here. Thanks to everyone who investigated and verified the fix!

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:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants