v1.76.0 ·
An agent that is not installed no longer stops the run
Autopilot died when the agent it was set up to run was not installed.
spawnDetached in packages/cli/src/autopilot/run.ts starts the agent and returns child.pid ?? -1. When the command cannot be started, because it is not on the PATH or not executable, Node gives the child no pid and emits an error event on the next tick. Nothing listened. The error was thrown, so the background aidlc autopilot run --foreground loop died, and a one-shot aidlc autopilot tick exited with a stack trace.
It left damage behind too. The pass had already saved the item as building with pid: -1 and said agent started (pid -1). The liveness check calls process.kill(-1, 0), which succeeds whenever the user may signal any process, so -1 read as a running agent. Every later pass waited on it. The item held a build slot and was never parked.
Nothing else would have caught it either. The exit listener that feeds the launch-failure park never fires for a spawn that fails. And even with the pid read as dead, the item would have fallen through to the session result: a Claude preset would park as "agent exited before the release boundary", a Codex preset would try to resume a session that never existed, and a relaunch at deployment would push and reopen its pull request. None of those names the cause.
What changed
The run now carries on. At its next check it parks the item with the reason the system gave, such as agent failed to launch: spawn codex ENOENT, frees the slot, and moves to the next ready item. An item already stuck this way by an older version is parked the same way at the first check after upgrading. Agents that start behave as before. It is a patch: no command, flag, config key or state field changed.
Why this way
A launch that never happened now gets its own negative number, one no real process can have, and the error that explains it is kept under that number until the next check reads it. The -1 placeholder was the whole bug, because asked whether -1 is alive, the system answers for every process the user owns.
I closed every road from that placeholder to a signal, not only the one in the report. The same number could reach the call that stops an agent over its cost limit, and stopping -1 would have sent a stop signal to every program the user had open. Both now refuse anything that is not a real pid. The tests replace the system's signal call with a stand-in, so a mistake cannot reach the machine running them.
I proved each guard by removing it. With the error handler gone, the test run printed the same unhandled error as the report. With each other guard gone, its tests failed. One removal showed a line in my plan was wrong: I had assumed a launch that never started would be retried, but it would only have been described afterwards as a session with no result. The guard stayed, and the record now says what it actually prevents.
packages/cli/test/autopilot-spawn-failure.test.ts holds the 22 new tests, and no existing test changed.