Skip to content

fix(server): fork Claude histories with bodyless system records - #216

Merged
pandec merged 1 commit into
devfrom
fix/claude-fork-system-history
Sep 22, 2026
Merged

pandec merged 1 commit into
devfrom
fix/claude-fork-system-history

Conversation

@pandec

@pandec pandec commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

What changed

Claude conversation forks now accept system history records without a message body, such as stop_hook_summary. User and assistant records still require that field. Fork validation preserves already-unknown turn boundaries while continuing to reject lost known boundaries or changed conversation content.

Why

Forking a real session failed with Missing key at [43]["message"] after the history worker serialized an undefined system-message body. Once decoding succeeded, an existing unknown first-turn boundary caused a second rejection. Both fixes use the existing history path shared by fork and rewind.

Validation

  • All 197 Claude adapter tests pass, including fork and rewind regressions and rejection of missing conversation bodies or known boundaries.
  • vp check passes with 0 errors and 886 existing warnings.
  • vp run typecheck passes.
  • A native SDK fork of an isolated transcript copy succeeds with all 1,298 history entries and 39 boundary entries preserved. Live sessions were not modified.

Checklist

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

Model: GPT-6. Harness: Codex.

Summary by CodeRabbit

  • Bug Fixes
    • Improved conversation history handling for system messages that do not include message content.
    • Preserved unknown conversation fork boundaries during session remapping.
    • Added validation for missing required user and assistant message content.
    • Improved rewind and fork validation for sessions containing incomplete history records.

@coderabbitai

coderabbitai Bot commented Sep 22, 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: pandec/t3code/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: c722e93c-83e2-44f7-9426-5aa3c0e6da04

📥 Commits

Reviewing files that changed from the base of the PR and between 5046fe5 and 39735f7.

📒 Files selected for processing (2)
  • apps/server/src/provider/Layers/ClaudeAdapter.test.ts
  • apps/server/src/provider/Layers/ClaudeAdapter.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The Claude adapter now accepts system session records without message bodies. Fork boundary remapping preserves unknown boundaries and rejects loss of known boundaries. Tests cover bodyless system, user, and assistant records and updated rewind history.

Changes

Claude fork handling

Layer / File(s) Summary
Session schema and boundary remapping
apps/server/src/provider/Layers/ClaudeAdapter.ts
The session schema allows system records to omit message. User and assistant records still require message. Boundary remapping preserves existing null entries and rejects known boundaries that remap to null.
Fork validation coverage
apps/server/src/provider/Layers/ClaudeAdapter.test.ts
Tests cover preserved unknown boundaries, missing boundary failures, bodyless system/user/assistant records, updated failure messages, and rewind history with a bodyless stop-hook-summary record.

Priority: ⬇️ Low

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

Change: Bug fix

Suggested reviewers: juliusmarminge

Merge Risk: ⚪ Minimal · up to 39735

Claude forks now accept bodyless system history records while preserving known conversation boundaries and continuing to reject invalid user or assistant records. The reported validation passes indicate the change is ready to merge.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: fixing Claude history forks that contain bodyless system records.
Description check ✅ Passed The description explains what changed, why it changed, and how it was validated. It includes the required checklist and correctly omits UI-specific evidence because the change is server-side.
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

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@pandec
pandec merged commit 5e4ef32 into dev Sep 22, 2026
2 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