You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(agent-session): report a CLI the supervisor could not spawn as missing, not a failed start - #35770
If Claude isn't installed where a chat runs, the chat should say "Claude wasn't found". Instead it said "Claude stopped before it finished starting", which points the user at the wrong problem.
What Changed
Before: when the claude command doesn't exist, a new Claude chat ends with "Claude stopped before it finished starting." Details show (code 127) spawn claude ENOENT. The real-WSL lane (Debian) caught this, but the same path runs on native Linux, macOS and SSH hosts.
After: the same chat ends with the missing-CLI message (cliMissing), the one that tells the user to install Claude. If the chat's folder is the thing that's gone, it ends with the missing-folder message (launchFolderMissing).
Mechanism: Claude runs under Orca's process supervisor. When the supervisor can't launch claude, it exits with code 127 and writes a spawn report to stderr. The Claude connection already reads that report and marks the exit error as "executable missing" (the existing test in claude-stream-json-connection.test.ts covers this). But a Claude chat counts as "started" before the process proves it can run, so the exit takes the unexpected-exit path. There, settleClaudeUnexpectedExit turned every observed exit into providerExited and threw the mark away. The start-failure wording then rewrote providerExited as providerStartFailed. Now, when the exit error says the executable or the launch folder is missing (the new shared check providerSpawnAbsent), it goes through providerStartupFailureFact, the same function that already words startup errors. That function already maps these marks to cliMissing and launchFolderMissing. Codex had the same drop in one place: when its process exits during acquisition, the ended event it sends used to be a plain providerExited. That event now goes through the same check.
Why
The classification already existed and was correct; one consumer ignored it. Reusing providerStartupFailureFact keeps one place that decides how a spawn failure reads. Making the start-failure wording guess from the stderr text instead would duplicate the classifier and lose the launch-folder case. Once a Codex session has started, its exit path stays as it is: an established session's process already ran, so a spawn ENOENT can't happen there.
User-risk: a Claude or Codex chat whose CLI really is missing now says "wasn't found" instead of "stopped before starting", on every host (native macOS/Linux, WSL, SSH). Only exits already marked as a spawn ENOENT change. Those can only happen before the CLI ever ran, so no crash from a CLI that was running gets relabelled. cliMissing and launchFolderMissing are existing failure kinds, so older paired clients already know how to word them.
Linked Issue
N/A (internal; found by the real-WSL lane audit on #34590)
Visual Proof
N/A: only the failure message changes, and that message is an existing one. The unit test asserts the failure kind.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
New case in src/main/claude/claude-structured-session-exit-blame.test.ts. It builds the exit error from a real supervisor spawn report (exit 127, spawn claude ENOENT) through the production classifier, and asserts the ended failure is cliMissing, both directly and after the start-failure wording. Before the fix it failed with providerExited. A second new case in src/main/codex/codex-structured-session-exit-blame.test.ts has the Codex process exit with a missing-CLI error while the session is still being acquired. It asserts the ended event's failure is cliMissing, and it failed with providerExited before the Codex change. Also run: pnpm tc, pnpm run typecheck:ci, pnpm test src/main/claude src/main/codex src/main/provider-process src/main/native-chat/agent-session-wire, pnpm run check:code-quality:changed. structured-agent-session-at-rest-commands.test.ts fails on this loaded machine with or without the change (3 of 4 runs failed on main without it). In the full run, claude-stop-ack-race.test.ts and two codex-accounts/legacy-wsl-runtime-auth-drain-* tests also failed. They pass when run alone, with this change and without it.
Real-CLI test not run: no test account on this machine; covered by the supervisor-report repro test.
Review
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
…not a failed start
The connection already flags a supervised exit 127 with a spawn ENOENT as a
missing executable, but the session's unexpected-exit settlement turned every
observed exit into providerExited, which startup then worded as
providerStartFailed. Route spawn absences through the startup failure fact so
they surface as cliMissing or launchFolderMissing.
…n exit
Codex's acquisition-time exit had the same drop as Claude's unexpected exit:
a spawn ENOENT already marked on the error became providerExited. Share one
providerSpawnAbsent predicate and route marked errors through the startup
failure fact in both.
nwparker
changed the title
fix(claude): report a CLI the supervisor could not spawn as missing, not a failed start
fix(agent-session): report a CLI the supervisor could not spawn as missing, not a failed start
Oct 29, 2026
The Claude exit lifecycle now classifies missing provider executables and launch folders as startup failures. A new test checks that a supervised ENOENT spawn failure produces a cliMissing classification in both the ended event and the start-failure fact.
Priority: Pending latest changes
Merge Risk: Minimal · previous review 407a2
Some startup failures may still show a generic message after an early stdin error. This is an existing limitation, not a newly introduced failure.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Title check
The title clearly and concisely describes the primary change: reporting an unspawnable CLI as missing instead of as a failed start.
Description check
The description is detailed and covers the user impact, mechanism, rationale, testing, scope, and compatibility considerations. It omits an actual linked issue and leaves the full validation checklist…
Full details: Description check
Explanation
The description is detailed and covers the user impact, mechanism, rationale, testing, scope, and compatibility considerations. It omits an actual linked issue and leaves the full validation checklist unchecked, but the content is otherwise substantially complete.
Full details: Docstring Coverage
Explanation
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 2 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches: 💡 1
📝 Generate docstrings: 💡
Commit to this branch
Create a new PR
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Supported by static analysis
Script executed:
rg -n 'connection\.close|childEnded|onFault|onExit|initProof|catch' src/main/claude/structured/claude-structured-session-acquisition.ts src/main/claude/claude-stream-json-connection.ts
rg -n 'findInErrorChain|failedAcquisitionRefusal|classifyStoreFailure|preSpawnFailureInWords' src/main/provider-process src/main/native-chat/agent-session-wire
sed -n '140,340p' src/main/claude/structured/claude-structured-session-acquisition.ts
sed -n '230,315p' src/main/claude/claude-stream-json-connection.ts
sed -n '1,140p' src/main/provider-process/provider-error-chain.ts
Repository: stablyai/orca
Length of output: 17465
Script executed:
set -o pipefail
rg -n -F --glob '*.ts' -e 'function resolveClaudeAcquisitionError' -e 'const resolveClaudeAcquisitionError' -e 'resolveClaudeAcquisitionError' -e 'connection.close()' -e 'connection.close(' -e 'structuredAgentSessionStartFailureFact' -e 'providerStartupFailureFact' src/main/claude src/main/native-chat/agent-session-wire
printf'\n--- resolver definitions and surrounding code ---\n'
rg -l -F --glob '*.ts' -- 'resolveClaudeAcquisitionError' src/main/claude |whileread -r f;doecho"FILE: $f"
rg -n -F -- 'resolveClaudeAcquisitionError'"$f"doneprintf'\n--- acquisition file tail and resolver source candidates ---\n'
sed -n '1,180p' src/main/claude/structured/claude-structured-session-acquisition.ts
sed -n '180,340p' src/main/claude/structured/claude-structured-session-acquisition.ts
printf'\n--- refusal and failure consumers ---\n'
sed -n '1,190p' src/main/native-chat/agent-session-wire/structured-agent-session-failure-text.ts
sed -n '1,210p' src/main/native-chat/agent-session-wire/structured-agent-session-failed-create-refusal.ts
Repository: stablyai/orca
Length of output: 33090
Script executed:
set -o pipefail
sed -n '1,180p' src/main/claude/claude-structured-session-close.ts
printf'\n--- acquisition exit-proof types and constructors ---\n'
rg -n -F --glob '*.ts' -e 'AgentSessionAcquisitionExitProvenError' -e 'AgentSessionAcquisitionRootExitObservedError' -e 'AgentSessionAcquisitionExitUnprovenError' -e 'class AgentSessionAcquisition' src/main/native-chat/agent-session-wire src/main
printf'\n--- close resolver callers and cleanup helpers ---\n'
sed -n '1,150p' src/main/claude/claude-structured-session-exit-lifecycle.ts
sed -n '1,100p' src/main/claude/structured/claude-structured-acquisition-release.ts
Repository: stablyai/orca
Length of output: 39831
Reapply the spawn-absence mark before acquisition refusal classification.
When the stdin error occurs first, handleUnexpectedEnd caches an error while managed.spawnAbsence is still null. onFault stores that same unmarked object in childEnded, and acquisition throws it before publication. resolveClaudeAcquisitionError does not add the mark when connection.close() succeeds. The final refusal therefore falls through to generic startup wording instead of cliMissing or launchFolderMissing.
Reapply the mark when root exit is observed. withProviderSpawnAbsence mutates the existing error, so the mark also reaches childEnded through the retained object.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
If Claude isn't installed where a chat runs, the chat should say "Claude wasn't found". Instead it said "Claude stopped before it finished starting", which points the user at the wrong problem.
What Changed
Before: when the
claudecommand doesn't exist, a new Claude chat ends with "Claude stopped before it finished starting." Details show(code 127) spawn claude ENOENT. The real-WSL lane (Debian) caught this, but the same path runs on native Linux, macOS and SSH hosts.After: the same chat ends with the missing-CLI message (
cliMissing), the one that tells the user to install Claude. If the chat's folder is the thing that's gone, it ends with the missing-folder message (launchFolderMissing).Mechanism: Claude runs under Orca's process supervisor. When the supervisor can't launch
claude, it exits with code 127 and writes a spawn report to stderr. The Claude connection already reads that report and marks the exit error as "executable missing" (the existing test inclaude-stream-json-connection.test.tscovers this). But a Claude chat counts as "started" before the process proves it can run, so the exit takes the unexpected-exit path. There,settleClaudeUnexpectedExitturned every observed exit intoproviderExitedand threw the mark away. The start-failure wording then rewroteproviderExitedasproviderStartFailed. Now, when the exit error says the executable or the launch folder is missing (the new shared checkproviderSpawnAbsent), it goes throughproviderStartupFailureFact, the same function that already words startup errors. That function already maps these marks tocliMissingandlaunchFolderMissing. Codex had the same drop in one place: when its process exits during acquisition, theendedevent it sends used to be a plainproviderExited. That event now goes through the same check.Why
The classification already existed and was correct; one consumer ignored it. Reusing
providerStartupFailureFactkeeps one place that decides how a spawn failure reads. Making the start-failure wording guess from the stderr text instead would duplicate the classifier and lose the launch-folder case. Once a Codex session has started, its exit path stays as it is: an established session's process already ran, so a spawn ENOENT can't happen there.User-risk: a Claude or Codex chat whose CLI really is missing now says "wasn't found" instead of "stopped before starting", on every host (native macOS/Linux, WSL, SSH). Only exits already marked as a spawn ENOENT change. Those can only happen before the CLI ever ran, so no crash from a CLI that was running gets relabelled.
cliMissingandlaunchFolderMissingare existing failure kinds, so older paired clients already know how to word them.Linked Issue
N/A (internal; found by the real-WSL lane audit on #34590)
Visual Proof
N/A: only the failure message changes, and that message is an existing one. The unit test asserts the failure kind.
Testing
New case in
src/main/claude/claude-structured-session-exit-blame.test.ts. It builds the exit error from a real supervisor spawn report (exit 127,spawn claude ENOENT) through the production classifier, and asserts theendedfailure iscliMissing, both directly and after the start-failure wording. Before the fix it failed withproviderExited. A second new case insrc/main/codex/codex-structured-session-exit-blame.test.tshas the Codex process exit with a missing-CLI error while the session is still being acquired. It asserts theendedevent's failure iscliMissing, and it failed withproviderExitedbefore the Codex change. Also run:pnpm tc,pnpm run typecheck:ci,pnpm test src/main/claude src/main/codex src/main/provider-process src/main/native-chat/agent-session-wire,pnpm run check:code-quality:changed.structured-agent-session-at-rest-commands.test.tsfails on this loaded machine with or without the change (3 of 4 runs failed on main without it). In the full run,claude-stop-ack-race.test.tsand twocodex-accounts/legacy-wsl-runtime-auth-drain-*tests also failed. They pass when run alone, with this change and without it.Real-CLI test not run: no test account on this machine; covered by the supervisor-report repro test.
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)