Skip to content

fix(agent-session): report a CLI the supervisor could not spawn as missing, not a failed start - #35770

Merged
nwparker merged 2 commits into
mainfrom
nwparker/cli-missing-classify
Oct 29, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/cli-missing-classify

Conversation

@nwparker

@nwparker nwparker commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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 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.
@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

The PR keeps missing-CLI and missing-folder errors from being reported as ordinary Claude exits.

  • Claude and Codex chats name missing spawn targets correctly.

No new actionable issues were found in the changes since the previous review.

Reviews (2) · Last reviewed commit: "fix(codex): report a CLI missing during ..." · Reviewed by Greptile

…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 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
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 1 minute.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

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: 6e37d5d4-6bbb-44d2-99fe-e827b0f12c8c
Commits

Reviewing files that changed from the base of the PR and between 407a237 and a65fb7d.

Files selected for processing: 4
  • src/main/claude/claude-structured-session-exit-lifecycle.ts
  • src/main/codex/codex-structured-session-acquire.ts
  • src/main/codex/codex-structured-session-exit-blame.test.ts
  • src/main/provider-process/provider-executable-missing.ts
Walkthrough

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: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning 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 Passed checks: 4 passed
Check name Status Explanation
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.
Title check Passed The title clearly and concisely describes the primary change: reporting an unspawnable CLI as missing instead of as a failed start.
Description check Passed 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.

❤️ Share

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

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1


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: 96aba56e-2d32-41e9-a9f9-00a7e5cf0c64
Commits

Reviewing files that changed from the base of the PR and between 1279d5f and 407a237.

Files selected for processing: 2
  • src/main/claude/claude-structured-session-exit-blame.test.ts
  • src/main/claude/claude-structured-session-exit-lifecycle.ts

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

Comment on lines +94 to +104
// A typed startup refusal or a spawn ENOENT keeps its next step; else provider exit vs host fault.
failure:
startupAcquisitionRefusal(exit.error) ||
providerExecutableMissing(exit.error) ||
providerLaunchFolderMissing(exit.error)
? providerStartupFailureFact(exit.error)
: providerExitObserved(exit.error)
? agentSessionFailureFact('providerExited', {
detail: providerDiagnosticOf(exit.error)
})
: agentSessionFailureFact('hostFault'),

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.

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 | while read -r f; do
  echo "FILE: $f"
  rg -n -F -- 'resolveClaudeAcquisitionError' "$f"
done
printf '\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.

Suggested fix
     if (managed.rootExitObserved && !exitReported) {
       exitReported = true
+      if (terminalError) {
+        terminalError = withProviderSpawnAbsence(terminalError, managed.spawnAbsence)
+      }
       handlers.onExit?.(terminalError, { expected: closing })

@nwparker
nwparker merged commit 7f2d223 into main Oct 29, 2026
53 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