feat(terminal): interpret signal-termination exit codes (port from kilocode#12698) - #78074
Merged
Conversation
Contributor
૮ >ﻌ< ა ci reviewran on 8de5cb3 — feat(terminal): interpret signal-termination exit codes for
|
Port from Kilo-Org/kilocode#12698: report signal-terminated commands with a human-readable note instead of a bare numeric exit code. Kilo's fix settles a signal-killed process as the conventional 128+signum exit code so its bash tool stops hanging. Hermes already produces numeric codes for signal deaths (subprocess -signum, or the shell's 128+signum), but the model saw a bare exit_code=-9 or 137 and burned turns mis-diagnosing (137 = OOM kill being the most common). This adapts the idea to Hermes' existing exit-code semantics tier: - _interpret_signal_exit(): maps negative codes (definite signal death) and the 128+signum band (hedged with 'usually') to a note naming the signal and its likely cause, wired into _interpret_exit_code() ahead of the per-command semantics table. - Curated signal table (SIGKILL/SIGSEGV/SIGTERM/SIGABRT/...) so ambiguous application exit codes are never mislabeled; uncurated 128+N codes stay silent, SIGINT is excluded (executor's interrupt-marker path owns rc=130). - Notes surface via the existing exit_code_meaning result field. E2E verified against real SIGSEGV/SIGKILL processes.
teknium1
force-pushed
the
kilocode-port/signal-exit-notes
branch
from
August 17, 2026 02:57
e355512 to
8de5cb3
Compare
teknium1
added a commit
that referenced
this pull request
Aug 17, 2026
…scout-slate wave Post-merge docs sweep for the Aug 16 scout slate. Two pages: - mcp.md: tool-result sanitization section — invisible Unicode TAG chars (U+E0000-E007F) stripped from results/resources/descriptions (#80689); vendor _meta surfaced to the model minus protocol-reserved modelcontextprotocol/mcp prefixes (#80712) - tools.md: tool result annotations section — signal-death exit notes (subprocess -signum definite, shell 128+signum hedged) (#78074); UTF-16 read_file transcoding with disclosure hint and 10MB cap (#80717) Security-policy docs (approvals/allowlist) intentionally untouched.
teknium1
added a commit
that referenced
this pull request
Aug 17, 2026
…scout-slate wave Post-merge docs sweep for the Aug 16 scout slate. Two pages: - mcp.md: tool-result sanitization section — invisible Unicode TAG chars (U+E0000-E007F) stripped from results/resources/descriptions (#80689); vendor _meta surfaced to the model minus protocol-reserved modelcontextprotocol/mcp prefixes (#80712) - tools.md: tool result annotations section — signal-death exit notes (subprocess -signum definite, shell 128+signum hedged) (#78074); UTF-16 read_file transcoding with disclosure hint and 10MB cap (#80717) Security-policy docs (approvals/allowlist) intentionally untouched.
lisajlau
pushed a commit
to lisajlau/hermes-agent
that referenced
this pull request
Aug 20, 2026
…scout-slate wave Post-merge docs sweep for the Aug 16 scout slate. Two pages: - mcp.md: tool-result sanitization section — invisible Unicode TAG chars (U+E0000-E007F) stripped from results/resources/descriptions (NousResearch#80689); vendor _meta surfaced to the model minus protocol-reserved modelcontextprotocol/mcp prefixes (NousResearch#80712) - tools.md: tool result annotations section — signal-death exit notes (subprocess -signum definite, shell 128+signum hedged) (NousResearch#78074); UTF-16 read_file transcoding with disclosure hint and 10MB cap (NousResearch#80717) Security-policy docs (approvals/allowlist) intentionally untouched.
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.
Summary
The terminal tool now tells the model why a command died when it was killed by a signal —
exit_code=137gets anexit_code_meaningnote naming SIGKILL and the likely OOM cause instead of leaving the model to burn turns re-running and mis-diagnosing.Ported from Kilo-Org/kilocode#12698 ("settle signal-terminated shell commands as 128 + signum"). Kilo's bug was a hang because their spawner produced no numeric code on signal death; Hermes already produces numeric codes (Python
subprocess-signum, or the shell's128+signum), so the adaptation targets the remaining gap: the model can't read them.Changes
tools/terminal_tool.py: new_interpret_signal_exit()wired into_interpret_exit_code()ahead of the per-command semantics table.subprocess) → "Command terminated by signal N: …" for a curated table (SIGKILL/SIGSEGV/SIGTERM/SIGABRT/SIGBUS/SIGFPE/SIGPIPE/SIGQUIT/SIGILL/SIGXCPU/SIGXFSZ), generic fallback for uncurated signums.128+signumband (shell convention, ambiguous — a program canexit 139) → hedged "usually means…" note, curated signals only; uncurated codes stay silent so legitimate application exit codes are never mislabeled.tests/tools/test_terminal_signal_exit.py: 26 tests covering both encodings, exclusions, hedging, and precedence over the command-semantics table (a SIGKILLed grep reports the signal, not "no matches").Validation
python3SIGSEGV (real process, E2E)exit_code: 139, no noteexit_code_meaning: Exit code 139 usually means … SIGSEGV (segmentation fault…)bash -c 'kill -9 $$'(E2E)exit_code: 137, no note… SIGKILL — often the kernel OOM killer …grepno-match / diff / existing semanticsE2E was run through the real
terminal_tool()with an isolated tempHERMES_HOMEand genuinely signal-killed processes, not mocks.Architectural notes
_interpret_exit_code) — zero new tool surface, no behavior change for non-signal exits.exit_code_meaningfield the model already knows from grep/diff semantics.Infographic