Repository navigation
fix(agents): report an agent killed by a signal as failed with exit 128+n - #188
Merged
Merged
Conversation
…28+n node-pty reports a process killed by a signal as exitCode 0 plus the signal. recordExit dropped the signal, so an agent killed with SIGKILL (out of memory, kill -9) was recorded as "done, exit 0": wait_for_agent returned done, get_agent_result said done and the saved session restored as exited. Record such an exit the way a shell does, as 128+signal (SIGKILL -> 137), mark the session failed and put the signal name first in the failure details. Every reader of the exit (wait_for_agent, get_agent_result, the session store, the HOME failure summary) already derives its state from the exit code, so they now agree. Exits CanvasTTY causes itself (closing a card, quitting) are unaffected: those sessions are removed before the kill, and the exit handler ignores them.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This was referenced Nov 1, 2026
Closed
On the Windows CI runner the checkout uses CRLF, so the source assertion added for the renamed line (a literal "\n" between two lines of TerminalManager.ts) did not match. It now accepts "\r?\n".
Contributor
Author
|
The failure was ours. On Windows the checkout uses CRLF, and the source assertion this PR changed in |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Split out of #160 as a small, independent PR on 1.8.5 (it touches only what 1.8.5 does not already cover). It does not depend on the other parts.
Problem
node-pty reports a process that a signal ended as
{ exitCode: 0, signal: 9 }.TerminalManager.recordExitonly looked atexitCode, so a subagent whose CLI was killed (out of memory,kill -9, a crashed wrapper) was recorded as done, exit 0.Before:
wait_for_agentreturnsreason: "done",exitCode: 0;get_agent_resultsaysstate: "done".After: the same kill is recorded as
exitCode: 137,status: "failed", and the failure details start withThe process was killed by signal SIGKILL (9).wait_for_agentreturnsfailed,get_agent_resultreturnsstate: "failed", the saved session restores as failed and HOME's failure summary shows 137 with the signal line.Change
process.onExitpasses the signal on torecordExit. A non-zero signal is recorded the way a shell reports it, as128 + signal, and its name (fromos.constants.signals) is the first line offailureDetails, followed by the masked screen lines that were already collected. One file insrc/changes (+20/-6).Why this and not less
Every reader of an exit already derives its state from
metadata.exitCode(waitFor,result,persistedTerminalSession,failureSummary). Converting the signal once, where the exit is recorded, makes all of them right without touching any of them. Mapping onlystatuswould leaveexitCode: 0next tofailed, and the session store and HOME summary would still disagree. 128+n is the convention shells and CI tools already use, so the number reads the same way it does in a terminal.What changes for existing workflows
Validation
tests/subagent-signal-exit.test.mjs:{ exitCode: 0, signal: 15 }must give143/failedwithSIGTERM (15)named in the card,wait_for_agent,get_agent_result, the saved session and the HOME failure summary;/bin/sleepunder node-pty killed with SIGKILL must give137/failed, and a real/usr/bin/truemust staydone/0(POSIX only).done/0instead offailed/143and137); with the fix all pass.tests/terminal-lifecycle.test.mjs: one source assertion follows the renamed line; it accepts CRLF (\r?\n), as the Windows checkout has.npm run build(typecheck),npm run audit:secrets, the eager renderer bundle check and the full test suite pass. Full suite: 2654 tests, 2648 pass, 0 fail, 6 skipped. The renderer is untouched (eager bundle unchanged against the other branches;renderer-bundle-splittingpasses).