Skip to content

fix(claude): start a resumed Claude chat when its SessionStart hook names a boot id - #48404

Merged
AmethystLiang merged 2 commits into
mainfrom
AmethystLiang/claude-resume-hook-session-id
Nov 24, 2026
Merged

AmethystLiang merged 2 commits into
mainfrom
AmethystLiang/claude-resume-hook-session-id

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Reopening an existing Claude chat could fail with "Claude couldn't start" on some Claude CLI versions. The CLI briefly reports a throwaway session id while it reopens the chat, and Orca took that as Claude starting the wrong conversation. Orca now ignores that one early report on a reopen.

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​74 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​74
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​22 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​17

What Changed

  • On a resumed start (--resume), a SessionStart:resume hook frame that names another session is ignored: it neither proves nor refuses the session.
  • Everything else is unchanged:
    • a foreign system/init still refuses startup
    • any other foreign SessionStart frame on a resume still refuses
    • a fresh start still refuses any foreign SessionStart frame
  • On a resumed start, identity is checked by the first turn's system/init, which carries the resumed id. A mismatch there still ends the session through the existing late-refusal path.
  • The rule moved into claudeForeignFrameRefusesStartup in claude-structured-init-proof.ts, with a unit test.

Why

Claude CLI 2.1.117 runs a resume's SessionStart hooks while it loads the transcript, before it switches to the resumed session, and stamps their stream-json frames with its random boot session_id. This was reproduced with the real 2.1.117 binary: a SessionStart hook plus --resume <id> prints hook frames with a different id. A current CLI (2.1.331) prints the resumed id. A fresh --session-id start and a fork (--fork-session --session-id) on 2.1.117 both print the expected id, so the check stays strict for them.

Any SessionStart hook triggers it, including Orca's own optional status hooks, so affected users saw Error: claude provider session expected on resumed chats and bots. Asking users to upgrade the CLI would leave older installs broken. Ignoring every foreign SessionStart frame would drop a check that is accurate on fresh starts. Checked against how comparable products handle this.

Linked Issue

Fixes #48370

Follow-ups for two older identity gaps found in review, not changed here: #48402, #48403.

Visual Proof

N/A: no UI change. The visible effect is that a resumed Claude chat starts instead of showing "Claude couldn't start".

Testing

  • I manually tested these changes locally: reproduced the frames with the real Claude CLI 2.1.117 binary (fresh, resume and fork launches) and compared against 2.1.331.
  • Automated tests added/updated: claude-structured-init-proof.test.ts uses the exact 2.1.117 resume frames.
  • Every added test fails without this change and avoids the test anti-patterns: with the old rule restored, the resumed-hook test fails.

Performance

None, because this only changes a string comparison on frames that already arrive during startup.

Risk

Level: Low. The riskiest case is a CLI that resumes into a different session and reports it only through a SessionStart:resume frame. That mismatch is now caught at the first turn's system/init instead of at startup. Back out with a plain revert.

…ames a boot id

Claude CLI 2.1.117 runs a resume's SessionStart hooks while it loads the transcript, before it
switches to the resumed session, so their stream-json frames carry a random boot session_id.
Orca read that as Claude starting a different session and failed the start with
"claude provider session expected". On a resume, a SessionStart hook frame naming another
session is now ignored; a foreign system/init still refuses, and fresh starts keep the check.

Fixes #48370
@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds foreign-frame startup classification that accounts for transcript resumes. Session acquisition now retains the completed launch record and uses it to classify foreign frames. Tests cover resumed and fresh sessions, including system/init, SessionStart hook frames, and ordinary status frames.

Merge Risk: Minimal · up to 67e6e

Claude sessions resumed with CLI 2.1.117 should no longer fail at startup because of the temporary boot ID on resume hooks. A foreign system/init or other foreign SessionStart frame still refuses startup as before. No merge-blocking risk remains.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive Issue #48370 reports "claude provider session expected" failures during startup, and its Expected section asks for either a more permissive wait for the first system/init frame or better logging of th… Provide the startup trace or logs for the failing sessions in #48370 that show whether each session used --resume. If the failing sessions include fresh starts, the PR does not cover them. Those fresh-start failures would need either a fix …
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the main change: a resumed Claude chat now starts when its SessionStart hook reports a boot id. It matches the fix in claudeForeignFrameRefusesStartup, which ignores a foreign session …
Description check Passed The description follows the template. It covers ELI5, What Changed, Why, Linked Issue (Fixes #48370), Visual Proof (N/A with reason), Testing, Performance, and Risk with a level. It explains the mecha…
Out of Scope Changes check Passed The changes stay within the startup-identity fix. The change in claude-structured-session-acquisition.ts stores the completed launch object so that claudeForeignFrameRefusesStartup(message, launched) …
Full details: Title check

Explanation

The title names the main change: a resumed Claude chat now starts when its SessionStart hook reports a boot id. It matches the fix in claudeForeignFrameRefusesStartup, which ignores a foreign session id on a SessionStart:resume frame during resumed starts. The title is specific and uses the fix(claude) convention.

Full details: Description check

Explanation

The description follows the template. It covers ELI5, What Changed, Why, Linked Issue (Fixes #48370), Visual Proof (N/A with reason), Testing, Performance, and Risk with a level. It explains the mechanism, the 2.1.117 reproduction, and the stricter checks kept for other cases. Minor gaps: the AI Disclosure, Agent skill upstream boundary, and Review sections are empty or unchecked, and the Testing checklist does not state the platforms tested. The template's Notes and Checklist sections are also absent. These gaps are not critical.

Full details: Out of Scope Changes check

Explanation

The changes stay within the startup-identity fix. The change in claude-structured-session-acquisition.ts stores the completed launch object so that claudeForeignFrameRefusesStartup(message, launched) can read resumesTranscript. It removes the direct refusal branch and moves that decision into the helper. The helper in claude-structured-init-proof.ts keeps system/init refusal unchanged. The test file claude-structured-init-proof.test.ts covers the new rule, including the strict cases (foreign system/init, fresh-start SessionStart, and non-resume hooks on resume). The PR description and the summary both identify these changes as part of the fix. No unrelated file or behavior change appears in the summary. The follow-up identity gaps (#48402, #48403) are explicitly excluded.

Full details: Linked Issues check

Explanation

Issue #48370 reports "claude provider session expected" failures during startup, and its Expected section asks for either a more permissive wait for the first system/init frame or better logging of the non-init payload. The PR implements neither. It instead targets a different mechanism: on a resumed start (--resume), a foreign SessionStart:resume hook frame is ignored (claudeForeignFrameRefusesStartup in claude-structured-init-proof.ts). The PR states that fresh starts still refuse any foreign SessionStart frame, and that a fresh --session-id start on CLI 2.1.117 prints the expected id. The issue describes failures on new chats ("opening any new Claude-powered chat"). The issue does not say whether the failing sessions were resumes. The PR's mechanism therefore covers the reported failures only if they were resumed starts. Whether the failing sessions were resumes cannot be determined from the issue text or the reviewed summary. The added unit test covers the 2.1.117 resume frames, and the PR reports a manual reproduction with the real CLI binary. Those results support the resume case only.

Resolution

Provide the startup trace or logs for the failing sessions in #48370 that show whether each session used --resume. If the failing sessions include fresh starts, the PR does not cover them. Those fresh-start failures would need either a fix for the reported timing behavior or a demonstrated cause on fresh starts. Confirm the resume-only scope against the reporter's logs before the linkage is accepted.

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

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e991cc00-2c7d-4529-84d4-45ea2576cf7f
Commits

Reviewing files that changed from the base of the PR and between 05095dd and 67e6ecc.

Files selected for processing: 3

  • src/main/claude/structured/lifecycle/claude-structured-session-acquisition.ts
  • src/main/claude/structured/startup/claude-structured-init-proof.test.ts
  • src/main/claude/structured/startup/claude-structured-init-proof.ts

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

@AmethystLiang
AmethystLiang merged commit e3f021d into main Nov 24, 2026
54 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.

[Bug]: "claude provider session expected" during startup — provider-open race on CLI 2.1.117 (3–4s openMs)

1 participant