Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions dokimi/changelog.d/20261203_100000_failed-call-exit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!--
Copyright (C) 2026 Intel Corporation
SPDX-License-Identifier: Apache-2.0
-->

### Fixed

- **A model call that failed and the run went on makes `skill routing` and `skill novelty atoms`, `probe` and `analyze` exit 1** (#1556) — a call that raised an error the commands do not expect (an extraction call, a probe wording call, a routing pick) was absorbed: the command exited 0, and `skill routing` wrote `"status": "ok"` with "1 failed" in its summary line. It now writes its result as before, then prints the failed calls with the first error and exits 1, as `catalog routing` already did; `skill routing` writes `"status": "partial"` (no `partial` block unless the cap stopped it too). A failed call in a run `--max-usd` stopped exits 1 too, not 3. A script that read exit 0 from these commands after a failed call may notice. A reply that does not parse stays exit 0, and `tools preference` and `repo hits judge` still record a failed item in their output and exit 0 (`docs/quickstart.md`, exit codes).
6 changes: 3 additions & 3 deletions dokimi/docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ failed check.
| Code | Meaning | Examples |
|------|---------|----------|
| 0 | The command ran and, if it checks something, the check passed. | |
| 1 | A verdict or a gate that ran and failed, or a runtime failure the command reports (a model call, a run, a clone or fetch); a crash that escapes is 5. `eval judge validate --strict` and `eval leak`/`eval redteam` that fail as blocked. | `baseline compare --max-context-drop 0` over a regression, `repo reach` with a harness binary that cannot run, `eval triggers generate --fail-on warn` over a lint finding |
| 1 | A verdict or a gate that ran and failed, or a runtime failure the command reports (a model call, a model call that failed and the run went on, a run, a clone or fetch); `skill routing`, `skill novelty atoms`, `probe` and `analyze` and `catalog routing` write their result first, with a status that is not `ok` where the file has one, while `tools preference` and `repo hits judge` record the failed item in their output and exit 0; a crash that escapes is 5. `eval judge validate --strict` and `eval leak`/`eval redteam` that fail as blocked. | `baseline compare --max-context-drop 0` over a regression, `repo reach` with a harness binary that cannot run, `eval triggers generate --fail-on warn` over a lint finding |
| 2 | A bad invocation: a missing, unreadable or malformed input file, a configuration the agent's CLI rejects (`repo run --tools all` with a `.mcp.json` the CLI does not accept: refused before any cell runs), a device given as one (`<flag> <path>: not a file`), a flag combination the command refuses, an output file that cannot be written, a missing provider credential, a source string that is malformed, unpinned or not a repository root. | `baseline save` on a bad eval file, `evaluate --questions` on an empty or non-JSON file (`--questions <path>: <reason>`), `benchmark preflight` with no golden set, `repo scan --manifest ../x.yaml` |
| 3 | Inconclusive: the run stopped short because a budget ran out (`--max-usd`, or a call with no price) and kept the partial output (`tools preference`, `skill novelty atoms`, `probe` and `analyze`, `skill routing` and `catalog routing`, `repo run` when the batch budget is the only reason a cell was not started (with a cell error or a failed probe too it exits 1, 5 for a cell that crashed of the machinery; a batch that started no cell exits 1), and `repo hits judge`; a stop on a permanent provider error, on 3 judge calls in a row failing with one error, or a `catalog routing` run with a failed model call, exits 1; `eval personas discover` refuses its one call before it runs, so nothing is written), or the result is undecided (`trace consistency --contract`: a rule depends on an unlabelled write; `eval judge validate`: a pass whose interval straddles the gate, or a variant no pair was built for, with `--strict` making it 1; `eval leak`: an item that could not be checked, or none could; `eval redteam`: a graded question not measured, or nothing graded; `eval judge agreement --strict`: an arm NOT MEASURED, or no arm to compare; `repo security --fail-on`: an unfinished cell or an arm with no measured cell, when no arm failed and every model has a baseline cell). | `tools preference --max-usd 5` with calls not run; `eval judge validate` with too few bases |
| 3 | Inconclusive: the run stopped short because a budget ran out (`--max-usd`, or a call with no price) and kept the partial output (`tools preference`, `skill novelty atoms`, `probe` and `analyze`, `skill routing` and `catalog routing`, `repo run` when the batch budget is the only reason a cell was not started (with a cell error or a failed probe too it exits 1, 5 for a cell that crashed of the machinery; a batch that started no cell exits 1), and `repo hits judge`; a stop on a permanent provider error, on 3 judge calls in a row failing with one error, or a `skill routing`, `skill novelty atoms`, `probe` or `analyze` or `catalog routing` run with a failed model call, exits 1; `eval personas discover` refuses its one call before it runs, so nothing is written), or the result is undecided (`trace consistency --contract`: a rule depends on an unlabelled write; `eval judge validate`: a pass whose interval straddles the gate, or a variant no pair was built for, with `--strict` making it 1; `eval leak`: an item that could not be checked, or none could; `eval redteam`: a graded question not measured, or nothing graded; `eval judge agreement --strict`: an arm NOT MEASURED, or no arm to compare; `repo security --fail-on`: an unfinished cell or an arm with no measured cell, when no arm failed and every model has a baseline cell). | `tools preference --max-usd 5` with calls not run; `eval judge validate` with too few bases |
| 4 | Invalid: the result is not comparable or not trustworthy: a model that differs from the baseline's, or one that cannot be verified, under `baseline compare --strict` or the regression gate (`--max-context-drop` or `--max-lift-drop`); under `repo security --fail-on`, a model with no baseline cell when no arm failed; under `eval judge agreement --strict`, an arm JUDGE-DEPENDENT; under `runs baseline save --expect-previous`, a baseline that no longer points to the run expected (a stale baseline, the pointer left as it was). | `baseline compare --strict` over a baseline scored with another judge |
| 5 | Infrastructure failure: a crash (an uncaught exception) in any command, with its traceback on stderr. For a command that emits the cli_output document, `--json` prints its `infra` document on stdout first. Also a `repo run` cell that crashes (a harness that exits nonzero before its first trace line, unless the cap killed it, a docker daemon or CLI failure that stops the agent, a scratch directory that vanished): the batch keeps the other cells and exits 5. | `backends --json` when `detect` raises; `repo run` with the docker daemon down |

Expand All @@ -277,7 +277,7 @@ or an unpriced model stopped it short, and `eval personas discover` exits 3 when
`skill novelty atoms`, `probe` and `analyze` and `skill routing` and `catalog routing` exit 3 when
the budget or an unpriced call stops them and they keep a partial file, and 1 when they keep
nothing (`skill shorten`, and a stop that leaves no partial file: "nothing was written") or a permanent provider error
stopped them or, in `catalog routing`, a model call failed (`catalog novelty` exits 1 too, once it has written
stopped them or a model call failed and the run went on (`catalog novelty` exits 1 too, once it has written
its rows, when any skill it took on is `partial`, `error` or not run).
`eval judge agreement` with a repeated `--judge` and `eval score pairwise` exit 1, not 2, when
every judge call fails, a missing provider credential included.
Expand Down
8 changes: 5 additions & 3 deletions dokimi/docs/skill-novelty.md
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,9 @@ Two numbers, reported side by side and never merged:
the gold card was shown at are recorded per query. **An abstention counts against
`selection_rate`** — not picking anything is the routing failure — with
`selection_rate_among_answered` beside it; a failed call is excluded from both and
counted, and one failed query does not lose the rest.
counted, and one failed query does not lose the rest. A run with a failed call writes
its result with `"status": "partial"` (no `partial` block unless the cap stopped it too)
and exits 1, naming `N of M model call(s) failed` and the first error.
Each abstention or unparseable pick keeps the model's raw reply under
`per_query[].raw_reply` (the first 2000 characters), so a decline can be read. A reply cut
at the output ceiling is an abstention too, whether or not its price is known.
Expand Down Expand Up @@ -1016,12 +1018,12 @@ fewer calls than the printed count. The response cache is opt-in: without `DOKIM
set to a writable directory nothing is stored, and a rerun pays for every call again. Set it for
research runs and for any run you may repeat. `--cache-dir` keeps only the retention verdicts.

**A permanent provider error that every call would meet stops a routing run the way the cap does.** An authentication or permission error, an unknown model ID (`not found`), a parameter the provider does not take (every call sends the same ones) or missing credentials (with `claude-cli`: not logged in, a usage limit, no `claude` binary; with AWS: "Unable to locate credentials", a missing config profile or an expired SSO session, whichever class litellm wraps it in) would fail every later call alike, so the run stops at that call, keeps the rows made before it and writes the partial result below, with `"reason": "permanent_error"` and the error text as the message (`--max-usd` is not involved; the exit line gives `calls_done` of `calls_planned`). Any other failure is one failed row and the run goes on: a refusal, a request one query makes too long, an unparseable reply, an error the client does not recognise, a transient error that ran out of retries. `skill novelty atoms`, `probe` and `analyze` and `skill shorten` stop the same way at the first such error in an atom extraction call, the faithfulness check, a probe wording, an answer, a grade, a value or conflict batch or a retention adjudication, and keep what they paid for as they do at the cap, with `"reason": "permanent_error"`; a refusal, an unparseable reply or a request one item makes too long is still one failed item.
**A permanent provider error that every call would meet stops a routing run the way the cap does.** An authentication or permission error, an unknown model ID (`not found`), a parameter the provider does not take (every call sends the same ones) or missing credentials (with `claude-cli`: not logged in, a usage limit, no `claude` binary; with AWS: "Unable to locate credentials", a missing config profile or an expired SSO session, whichever class litellm wraps it in) would fail every later call alike, so the run stops at that call, keeps the rows made before it and writes the partial result below, with `"reason": "permanent_error"` and the error text as the message (`--max-usd` is not involved; the exit line gives `calls_done` of `calls_planned`). Any other failure is one failed row and the run goes on: a refusal, a request one query makes too long, an unparseable reply, an error the client does not recognise, a transient error that ran out of retries. Such a failed row or item is a model call that failed and the run went on: `skill routing`, `skill novelty atoms`, `probe` and `analyze` write their result and then exit 1 (an atom extraction call or a probe wording call that raised; a reply that does not parse is not one, and exits 0 as before). `skill novelty atoms`, `probe` and `analyze` and `skill shorten` stop the same way at the first such error in an atom extraction call, the faithfulness check, a probe wording, an answer, a grade, a value or conflict batch or a retention adjudication, and keep what they paid for as they do at the cap, with `"reason": "permanent_error"`; a refusal, an unparseable reply or a request one item makes too long is still one failed item.

**A routing run stopped by `--max-usd` keeps what it paid for.** `skill routing --model`, single
artifact or `catalog routing`, writes the result of the calls made before the cap (or a call with no
known price) stopped it, prints the summary and `cost` lines, and exits 3 with the
cap message and the path of the file (1 for a `permanent_error` stop, and for an all-vs-all run with a failed model call, whose message then ends with `N of M model call(s) failed, so this exits 1`). The file carries
cap message and the path of the file (1 for a `permanent_error` stop, and for a run with a failed model call, whose message then names the failed calls and ends with `so this exits 1`). The file carries
`"partial": {"reason": "spend_cap", "calls_done": N, "calls_planned": M, "message": ...}` (`"permanent_error"` for the stop above, `"no_price"` for an unpriced call) at the
top level (and under the model arm), and no `partial` key when the run finished. The record's
`status` is then `"partial"` instead of `"ok"` (a single run; an all-vs-all file carries `status`
Expand Down
25 changes: 20 additions & 5 deletions dokimi/dokimi/commands/novelty.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ def cmd_novelty_analyze(args: argparse.Namespace) -> None:
render_novelty_markdown,
)

from dokimi.commands.novelty_budget import print_estimate_only, print_run_estimate
from dokimi.commands.novelty_budget import (
analyze_failed_calls,
exit_if_calls_failed,
print_estimate_only,
print_run_estimate,
)
from dokimi.novelty import cli_preset

cli_preset.apply(args)
Expand Down Expand Up @@ -117,12 +122,18 @@ def cmd_novelty_analyze(args: argparse.Namespace) -> None:
print(f"OK Saved atom verdicts: {atom_verdicts_path}")
print(f"OK Saved atoms: {atoms_path}")
_print_headline(result.artifact)
exit_if_calls_failed(analyze_failed_calls(result), out_json)


def cmd_novelty_atoms(args: argparse.Namespace) -> None:
"""Extract atoms and spans only — the expensive stage, cached for reuse."""
from dokimi.novelty import cost
from dokimi.commands.novelty_budget import save_atoms_run, verify_or_partial
from dokimi.commands.novelty_budget import (
exit_if_calls_failed,
failed_calls_note,
save_atoms_run,
verify_or_partial,
)
from dokimi.novelty.atoms import ExtractionError, ExtractionReport, extract_atoms, sample_atoms
from dokimi.novelty.report import cap_warning
from dokimi.novelty.spans import segment, span_summary
Expand All @@ -147,11 +158,13 @@ def cmd_novelty_atoms(args: argparse.Namespace) -> None:
if settings.values["verify_faithfulness"] and partial is None:
partial = verify_or_partial(sample, spans, extractor)
out = Path(args.out) if args.out else default_dir(args.artifact) / "atoms.json"
save_atoms_run(atoms, spans, out, partial, extractor=extractor.model,
failed = failed_calls_note(extraction, n_spans=len(spans))
save_atoms_run(atoms, spans, out, partial, failed=failed, extractor=extractor.model,
extractor_provider=extractor.provider, cap=cap,
bundle=artifact_bundle.summary(), extraction=extraction, sample=sample)
print(f"OK Saved {len(atoms)} atoms ({len(sample)} sampled) over {len(spans)} spans: {out}")
print(json.dumps(span_summary(spans, atoms), indent=2))
exit_if_calls_failed(failed, out)


def cmd_novelty_probe(args: argparse.Namespace) -> None:
Expand All @@ -165,7 +178,7 @@ def cmd_novelty_probe(args: argparse.Namespace) -> None:
from dokimi.novelty.measure import SelfJudgeError, check_self_judge, run_measurement
from dokimi.novelty.probes import build_probe_set
from dokimi.novelty.report import build_probe_record
from dokimi.commands.novelty_budget import save_probe_measure
from dokimi.commands.novelty_budget import exit_if_calls_failed, failed_calls_note, save_probe_measure
from dokimi.novelty import cli_preset

preset = cli_preset.apply(args, report=False) # roles and refusals now; the warnings once the key is known
Expand Down Expand Up @@ -225,7 +238,8 @@ def cmd_novelty_probe(args: argparse.Namespace) -> None:
stamp(payload, args, result, answerer=answerer, judge=judge, judge2=judge2)
out = Path(args.out) if args.out else default_dir(args.artifact) / "probes.json"
# A run the cap stopped keeps the answers it paid for, as a partial result (and exits).
save_probe_measure(payload, out, result)
failed = failed_calls_note(probe_set=probe_set)
save_probe_measure(payload, out, result, failed)
print(f"OK Saved {len(result.runs)} probe runs: {out}")
for scoring in ("lenient", "strict"):
row = payload["paired"][scoring]
Expand All @@ -234,6 +248,7 @@ def cmd_novelty_probe(args: argparse.Namespace) -> None:
f"degraded {row['degraded']} still-missing {row['still_missing']} "
f"(n={row['n_paired']})"
)
exit_if_calls_failed(failed, out)


def _write_item_analysis(payload: dict, out: Path) -> None:
Expand Down
Loading
Loading