fix(learn): treat a wrapped exited-with status as one clause; classify Killed: N

A line that ends at "exited with" continues on the next line, so "Process exited
with\nexit code 0" stays a success. The shared classifier maps the numbered shell
message "Killed: 9" to exit_code, matching what the detector already accepts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Tejas Chopra
2026-10-09 22:26:28 -07:00
co-authored by Claude Opus 5.5
parent e063c64b1e
commit 98f9ea570c
3 changed files with 11 additions and 3 deletions
+4 -1
View File
@@ -71,7 +71,10 @@ _ERROR_PATTERNS: list[tuple[re.Pattern[str], ErrorCategory]] = [
(re.compile(r"[Ss]ibling tool call errored", re.I), ErrorCategory.SIBLING_ERROR),
# A signal kill is the shell's exit status 128+N, so it shares EXIT_CODE.
(
re.compile(r"exit code|non-zero|exited with|killed by signal|^\s*Killed\s*$", re.I | re.M),
re.compile(
r"exit code|non-zero|exited with|killed by signal|^\s*Killed(?::\s*\d+)?\s*$",
re.I | re.M,
),
ErrorCategory.EXIT_CODE,
),
(
+3 -2
View File
@@ -243,7 +243,8 @@ _ERROR_SIGNALS: tuple[re.Pattern[str], ...] = (
# nonzero (signed codes such as -9 included). Status evidence belongs to its own
# line: a zero code never hides a separate explicit failure elsewhere in the
# output (a nonzero code, "non-zero", a signal kill, or an "exited with ..." line
# that carries no code of its own).
# that carries no code of its own). A line that ends at "exited with" continues
# on the next line ("Process exited with\nexit code 0"), so it is not a failure.
# A standalone "Killed" line is the shell's SIGKILL message, but a successful
# command can also print that word, so it counts only when no exit status is
# reported at all. It is recognized even below the short-content cut-off.
@@ -252,7 +253,7 @@ _EXIT_STATUS_RE = re.compile(
)
_EXIT_FAILURE_RE = re.compile(r"non-zero|nonzero|exited with signal|killed by signal", re.I)
_KILLED_LINE_RE = re.compile(r"^\s*Killed(?::\s*\d+)?\s*$", re.M)
_EXITED_WITH_RE = re.compile(r"exited with", re.I)
_EXITED_WITH_RE = re.compile(r"exited with(?=\s*\S)", re.I)
def _exit_status_is_error(snippet: str) -> bool:
@@ -84,6 +84,9 @@ class TestErrorClassification:
("Killed\nexit code 0", False),
# The wrapper's zero status belongs to its own line.
("worker exited with an error\nwrapper exit code 0", True),
# One status phrase wrapped across lines is still one zero status.
("Process exited with\nexit code 0", False),
("Killed: 9", True),
# Case-insensitive signals the shared is_error_content would miss.
("zsh: no such file or directory: ./run.sh", True),
("fatal: path 'x' does not exist in 'HEAD'", True),
@@ -127,6 +130,7 @@ class TestErrorClassification:
("ConnectionError: [Errno 111] Connection refused", "connection_error"),
("task killed by signal SIGKILL", "exit_code"),
("python train.py\nKilled", "exit_code"),
("Killed: 9", "exit_code"),
],
)
async def test_error_category_recorded(