Skip to content

Don't report a failed subprocess start on os-lib's threads - #303

Open
adamw wants to merge 2 commits into
masterfrom
fix-missing-agent-cli
Open

adamw wants to merge 2 commits into
masterfrom
fix-missing-agent-cli

Conversation

@adamw

@adamw adamw commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

What was wrong

When the agent CLI (e.g. claude) is not on PATH, a run printed up to four lines like [orca] uncaught exception on thread 'subprocess-shutdown-hook-monitor': Cannot run program "claude". The failure itself was handled correctly; the lines were noise.

Why

os-lib's spawn registers a shutdown hook, and starts a monitor thread that removes it, before it starts the process. When the start fails, the monitor thread tries to start the process again and dies with the error. The hook stays registered, and at JVM exit it tries the start once more and dies too. Each spawn attempt gives two lines.

Fix

New orca.subprocess.Spawn: calls os-lib with destroyOnExit = false, and registers the shutdown hook only after the process has started (removed on process exit). The process is still destroyed on JVM exit, as before.

Used by OsProcCliRunner.spawnPiped, QuietProc.call/callCapped (so a missing gh is covered too), and in the shell by the slug-naming call, session resume, the editor and the flow launch (Spawn.inheritingStdio for the ones on the terminal's stdio). A few direct os-lib calls of git, bash and test are left as they are.

Not done: up-front CLI check

A run still creates its branch and commits the progress log before it finds the CLI missing. A check before setup needs a "is my CLI on PATH" method on each of the five backends (so test fakes don't trip it), and a decision on which roles to check: a flow may never use the review role, so refusing because its CLI is missing could break runs that work today. Left as a follow-up.

Testing

  • New tests in OsProcCliRunnerTest and QuietProcTest: starting a missing program throws to the caller and no os-lib thread dies. Both fail without the fix.
  • SpawnTest: the shutdown hook is removed once the process exits.
  • testFull, scalafmtCheckAll green.
  • Live: orca run quick.sc with claude removed from PATH prints no uncaught-exception lines.

🤖 Generated with Claude Code

adamw added 2 commits October 22, 2026 14:36
os-lib registers its destroy-on-exit shutdown hook, and starts a thread
that removes it, before starting the process. When the start fails (for
example the agent CLI is not on PATH), both retry the start and print the
failure as an uncaught exception. Spawn with destroyOnExit = false and
register the hook only after the process has started.
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