Skip to content

fix(novelty): exit 1 after a failed model call the run went on past (#1556) - #1600

Merged
antonwolfy merged 5 commits into
intel:mainfrom
antonwolfy:fix/failed-call-exit
Dec 4, 2026
Merged

antonwolfy merged 5 commits into
intel:mainfrom
antonwolfy:fix/failed-call-exit

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

#1556: when one model call of a run raised an error nobody expects and the run went on, the exit code depended on the command. On main, with a fake model whose second call raises:

Command Exit on main Now
skill routing (3 queries, 1 call raises) 0, result "status": "ok", only "1 failed" in the summary line 1, "status": "partial"
skill novelty atoms (200 spans, 25 lost to the failed call) 0, a warning 1, atoms.json written
skill novelty probe (a wording call raises) 0, a warning that wordings were dropped 1, probes.json written
skill novelty analyze (a wording call raises) 0, a warning 1, novelty.json written with a warning
catalog routing 1 1 (unchanged)

Option taken (the issue's proposal, decided by its author): exit 1, after the result is written, reusing stop_partial and the failed_calls reason that catalog routing already uses. A failed call in a run --max-usd stopped exits 1 too (as catalog routing already says), not 3. A reply that did not parse (a malformed wording, a cut reply) is not a failed call and stays exit 0. tools preference and repo hits judge keep recording a failed item in their output and exiting 0, and docs/quickstart.md now says so. eval personas discover (exit 5, #1555) is untouched.

Closes #1556

Changes

  • skill routing (commands/novelty_routing.py): a model arm with n_failed > 0 writes "status": "partial", prints N of M model call(s) failed (first error: ...) and exits 1; with --json the document says partial with that reason, then the exit stands.
  • skill novelty atoms, probe, analyze (commands/novelty.py, commands/novelty_budget.py): failed_calls_note names the spans lost to failed extraction calls (ExtractionReport.failed_spans) and the wording calls that raised (ProbeSet.failed_calls, set in novelty/probes.py); exit_if_calls_failed exits 1 after the result is saved and printed. Atoms and probe files keep no status on a finished run, so probe still reads an atoms file that has unread spans. In a cap-stopped run exit_partial ends the message with the failed calls and exits 1.
  • A wording call that raised any error counts as failed, a ValueError from the transport included: _generate (novelty/probes.py) makes the call with client.text and parses its reply in a second step, so only a reply that is no array, or one cut at the output ceiling, stays no failed call.
  • analyze warns N wording call(s) failed in its artifact (novelty/analyze.py); AnalyzeResult carries probe_set.
  • docs/quickstart.md: exit-code row 1, the exit 3 row's clause and the paragraph below the table; docs/skill-novelty.md: the routing and permanent-error paragraphs.
  • Tests: tests/test_failed_call_exit.py (new); tests/test_novelty_routing_cost.py::test_a_model_run_whose_every_call_fails_prints_no_price_blame pinned exit 0 for a run whose every call fails, and now expects exit 1 with the result written.
  • Changelog fragment (Fixed).

Follow-ups, not in this PR:

Risk

A script that read exit 0 from skill routing, skill novelty atoms, probe or analyze after a failed call now sees 1 (and for skill routing a partial status instead of ok). The result file is still written, and a cap-stopped run with a failed call exits 1 instead of 3. The merge of main resolved one conflict, in the exit-3 row of docs/quickstart.md, which #1408 also edited: that row keeps main's trace consistency --contract clause and this PR's skill routing, skill novelty atoms, probe or analyze clause. Open PRs #1578 (commands/novelty.py), #1249 (tests/test_novelty_analyze.py) and #1190 (commands/novelty.py, commands/evaluate.py, commands/repo.py) also conflict with this branch in the files named; whichever merges second rebases. #1590, #1565, #1562 and #1515 merge cleanly with it.

Testing

On a Linux review host, at 9a287c67 (on main 691253e3):

  • make ci-local: 38 passed, 0 failed, 16 skipped (docker, semgrep, conda, other-matrix jobs). The test step: 35715 passed, 28 skipped. The test_import_architecture.py::test_package_uses_the_new_modules failure of the previous head is gone with the merge of main (fix(runs): import InputError from dokimi.files, not dokimi.utils #1609 changed the dokimi.runs.resolve import); that file passes (56 passed).
  • The reproduction of Exit code when a model call fails and the run goes on: 0, 1 or 5 by command, and the exit-code table does not decide it #1556 (skill routing, second of three calls raises): exit 0 status ok on main, exit 1, status partial here. On main 10 of the 18 tests of the new file fail (10 failed, 8 passed; the first on assert 0 == 1); the 8 that pass there are the no-failed-call controls.
  • Mutants: each assertion block of the new tests fails on a break of the code it covers (counted failed call in routing, the status write, the cap case, the --json status, failed_spans, a malformed reply counted as failed, the analyze warning, the analyze exit, the cap passthrough in probe, atoms and analyze).
  • A wording transport that raises ValueError("provider failure") (test_novelty_probe_with_a_wording_transport_raising_value_error_is_a_failed_call_and_exits_1): exit 1 with 1 wording call(s) failed (last error: ValueError: provider failure); at the previous head the test fails, since the ValueError was not counted. A wording reply cut at the output ceiling (test_a_wording_reply_cut_at_the_output_ceiling_is_no_failed_call) records no failed call; with that exemption removed the test fails. With the failed-calls reason of exit_partial replaced by the stop's own, the three cap-stop tests that expect exit 1 fail.
  • Not run: Python 3.11, 3.12 and 3.14; Windows; docker steps.

Open questions

None.

Revert

A plain revert restores exit 0 (and "status": "ok" for skill routing) after a failed call. Nothing is stored: result files written under the new behaviour keep the status partial they were given.

Checklist

  • Tests added/updated and pytest passes [the full run has 1 failure, test_import_architecture.py::test_package_uses_the_new_modules, which fails on main too (runs/resolve.py imports dokimi.utils)]
  • ruff, mypy, and schema checks pass
  • Docs updated (or N/A) — see the docs-drift checklist in CONTRIBUTING.md
  • Self-reviewed per "Before opening a PR" in AGENTS.md
  • Each new raise/exit and test names the doc, contract or issue it traces to
  • No ad-hoc run artifacts committed
  • New files carry the SPDX license header (or are exempt in .github/.licenserc.yaml)

`skill routing`, `skill novelty atoms`, `probe` and `analyze` absorbed a model call that raised an error nobody expects: they exited 0, and `skill routing` wrote `"status": "ok"` with only "1 failed" in its summary line, while `catalog routing` already exited 1.

They now write their result as before, print the failed calls with the first error, and exit 1 (`stop_partial` with the `failed_calls` reason, the code `catalog routing` uses). `skill routing` writes `"status": "partial"`; atoms and probe files have no status on a finished run and keep none, so `probe` still reads an atoms file with unread spans. A failed call in a run `--max-usd` stopped exits 1 too, as in `catalog routing`. A reply that does not parse (a malformed wording, a cut reply) is not a failed call and still exits 0. `tools preference` and `repo hits judge` keep recording a failed item in their output and exiting 0.

The extraction report counts the spans lost to failed calls (`ExtractionReport.failed_spans`), the probe set lists the wording calls that raised (`ProbeSet.failed_calls`), and `analyze` warns about them in its artifact. `docs/quickstart.md` and `docs/skill-novelty.md` say which command exits what.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy
antonwolfy requested a review from a team as a code owner December 3, 2026 14:38
Copilot AI balanced review requested due to automatic review settings December 3, 2026 14:38
@antonwolfy antonwolfy self-assigned this Dec 3, 2026
@exai-bot

exai-bot commented Dec 3, 2026 •

Copy link
Copy Markdown

✅ OpenCodeReview: Review complete: 0 finding(s) across 11 selected item(s).

CI at 9a287c6: 21 passing, 4 skipped.

Review details
  • Commit reviewed: 9a287c6 against merge base 691253e
  • Coverage: 11 files in 2 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 599k tokens (441k from cache), 1m10s
  • Tool calls: 48 (31 file_read, 10 code_search, 3 file_read_diff, 2 ci_status, 2 local_check_results)
  • Failed-call CLI exit behavior, documentation, and regression tests: 6 files
  • Novelty routing, probe failure handling, and cost accounting: 5 files

Comment thread dokimi/dokimi/novelty/probes.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open issues
What changed in this PR

Aligns CLI exit codes across novelty/routing commands so that unexpected model-call failures that don’t stop the run still produce artifacts but now exit with code 1 (and routing results become status: partial), per #1556.

Changes:

  • Update skill routing and skill novelty atoms|probe|analyze to write results and then exit 1 when a model call failed but the run continued.
  • Track and surface failed-wording calls in ProbeSet, and failed-span counts in extraction reporting.
  • Add/adjust tests and documentation to codify the new exit-code behavior.
File Description
dokimi/​tests/​test_novelty_routing_cost.py Updates expectations to exit 1 after a failed model call while still writing routing.json.
dokimi/​tests/​test_failed_call_exit.py Adds new end-to-end-ish tests covering exit codes, partial statuses, and “failed call” messaging.
dokimi/​dokimi/​novelty/​probes.py Records failed wording calls and threads that state through wording generation.
dokimi/​dokimi/​novelty/​atoms.py Adds failed_spans calculation and reuses it in warnings.
dokimi/​dokimi/​novelty/​analyze.py Carries probe_set through results and emits warnings when wording calls failed.
dokimi/​dokimi/​commands/​novelty_routing.py Marks failed routing calls as status: partial, emits reason, and exits 1 post-write.
dokimi/​dokimi/​commands/​novelty_budget.py Adds helpers for “failed call” notes and ensures capped runs exit 1 if failures occurred.
dokimi/​dokimi/​commands/​novelty.py Applies “exit 1 after write” behavior to atoms/probe/analyze flows.
dokimi/​docs/​skill-novelty.md Documents partial status + exit 1 behavior for failed calls.
dokimi/​docs/​quickstart.md Updates exit code table and explanatory text for failed-call behavior.
dokimi/​changelog.d/​20261203_100000_failed-call-exit.md Changelog entry describing the fixed behavior regression.

Review effort: Lite

Comment thread dokimi/dokimi/novelty/probes.py Resolved
Conflict in dokimi/docs/quickstart.md: both sides edited the exit 3 row of the exit-code table. Kept main's row (with its `trace consistency --contract` addition) and applied this branch's change to it: a `skill routing`, `skill novelty atoms`, `probe` or `analyze` run with a failed model call exits 1, like `catalog routing`.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
…as failed (intel#1556)

A wording call that raised ValueError before returning a reply was left out of failed_calls, because json_array wraps both the call and the parse and the check excluded every ValueError. _generate now makes the call with client.text and parses its reply in a second step: any error of the call is recorded (a reply cut at the output ceiling, OutputTruncated, is still no failed call), and only a reply that is no array stays exempt.

exit_partial ends in one stop_partial call whose message and reason the failed branch replaces, so the second call is no longer an unreachable line after the first.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy

Copy link
Copy Markdown
Contributor Author

Review points answered at ba37c2e; 1 checks still pending (Windows smoke test (py3.13)); failed: Test Linux Python 3.14, Test Linux Wheels Python 3.14, Tests (py3.14).

Declined, with the evidence in the replies:

  • dokimi/dokimi/novelty/probes.py:638 (Copilot): SpendCapReached is a BaseException (spend.py:124), so except Exception in _generate does not catch it; a transport raising it propagates to _worded's cap path.
  • dokimi/dokimi/commands/novelty_routing.py:191 (Copilot): next() cannot raise: n_failed counts the rows of per_query that hold an error (routing.py:384), so one exists whenever the early return is passed.

Follow-up issues opened:

Test Linux Python 3.14 fails the same tests on main (its latest run, at b4a842d): not this PR's change.
Test Linux Wheels Python 3.14 fails the same tests on main (its latest run, at b4a842d): not this PR's change.

@napetrov napetrov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change class: CONTRACT (head ba37c2e)

  • Contract: changed. defaults dokimi/dokimi/commands/novelty_budget.py:66; defaults dokimi/dokimi/commands/novelty_budget.py:78
  • Responsibility: none
  • Dependency: none
  • Review depth: check the changed surface: callers, docs, tests pin new behaviour
  • Coverage gaps: none

Ready to merge.

Rechecked transport errors, malformed and truncated replies, and exit codes after saving results. 28 focused tests and required CI passed. The optional jobs show the file-length failure on main (#1605) and a runner shutdown.

@antonwolfy

Copy link
Copy Markdown
Contributor Author

(approved) ### Change class: CONTRACT (head ba37c2e)

@napetrov (#1600 (review)): Nothing to change. The review's findings match what I checked at this head: the PR's tests pin the exit codes and the new defaults in dokimi/dokimi/commands/novelty_budget.py. The file-length failure it names on the optional jobs is tracked in #1605.

@antonwolfy

Copy link
Copy Markdown
Contributor Author

Review points answered at ba37c2e; 1 checks still pending (Tests (py3.14)); failed: Test Linux Python 3.14, Test Linux Wheels Python 3.14.

Declined, with the evidence in the replies:

@codecov-commenter

codecov-commenter commented Dec 4, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.45%. Comparing base (3cf65d7) to head (9a287c6).
⚠️ Report is 1 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1600      +/-   ##
==========================================
- Coverage   96.46%   96.45%   -0.02%     
==========================================
  Files         566      566              
  Lines       74980    75032      +52     
  Branches    12949    12958       +9     
==========================================
+ Hits        72328    72369      +41     
- Misses       1628     1634       +6     
- Partials     1024     1029       +5     
Files with missing lines Coverage Δ
dokimi/dokimi/commands/novelty.py 98.31% <100.00%> (+0.02%) ⬆️
dokimi/dokimi/commands/novelty_budget.py 97.35% <100.00%> (+0.31%) ⬆️
dokimi/dokimi/commands/novelty_routing.py 97.95% <100.00%> (+0.24%) ⬆️
dokimi/dokimi/novelty/analyze.py 99.01% <100.00%> (+<0.01%) ⬆️
dokimi/dokimi/novelty/atoms.py 98.82% <100.00%> (+0.01%) ⬆️
dokimi/dokimi/novelty/probes.py 100.00% <100.00%> (ø)

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@antonwolfy

Copy link
Copy Markdown
Contributor Author

Review points answered at ba37c2e; failed: Test Linux Python 3.14, Test Linux Wheels Python 3.14, Tests (py3.14).

Declined, with the evidence in the reply:

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy antonwolfy added the testing-strategy Part of #1595: checks for the bug classes behind our fix series, their sweeps and research label Dec 4, 2026
@antonwolfy

Copy link
Copy Markdown
Contributor Author

Review points answered at cdecdb8; failed: Test Linux Python 3.14, Test Linux Wheels Python 3.14, Tests (py3.14).

Declined, with the evidence in the replies:

Follow-up issues opened:

Test Linux Python 3.14 fails the same tests on main (its latest run, at 101e0b9): not this PR's change.
Test Linux Wheels Python 3.14 fails the same tests on main (its latest run, at 101e0b9): not this PR's change.
Tests (py3.14) fails the same tests on main (its latest run, at 101e0b9): not this PR's change.

Conflicts, both in the novelty commands, resolved by keeping both sides.

- dokimi/dokimi/commands/novelty.py: main's `cli_preset` import and its `cli_preset.apply(args)` calls sit beside this branch's failed-call helpers (`analyze_failed_calls`, `exit_if_calls_failed`, `failed_calls_note`) in `cmd_novelty_analyze` and `cmd_novelty_probe`.
- dokimi/dokimi/commands/novelty_routing.py: `skill routing` keeps main's `call_cap` as a budget_stopped reason and this branch's `partial` status with the failed call's message when no cap stopped the run.

docs/reference/cli-interface.json rebuilt by scripts/cli_surface.py dump: unchanged.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy
antonwolfy merged commit 4024f25 into intel:main Dec 4, 2026
25 checks passed
@antonwolfy
antonwolfy deleted the fix/failed-call-exit branch December 4, 2026 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing-strategy Part of #1595: checks for the bug classes behind our fix series, their sweeps and research

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exit code when a model call fails and the run goes on: 0, 1 or 5 by command, and the exit-code table does not decide it

5 participants