Skip to content

feat(verification): keep a judge's unparseable verdict kind, check materialized task rows, allow judge-optional grading - #6145

Closed
AdamRajfer wants to merge 2 commits into
mainfrom
arajfer/judge-reask-unparseable
Closed

AdamRajfer wants to merge 2 commits into
mainfrom
arajfer/judge-reask-unparseable

Conversation

@AdamRajfer

@AdamRajfer AdamRajfer commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What

Three small, independent changes to shared verification and validation code:

  • Unparseable judge verdicts keep their kind. A JudgeError raised by a parser can carry failure_kind="judge_unparseable" (a judge that answered without a valid verdict on every attempt). judge_failsafe masks the row under that kind, still routed as judge_failed so the saved answer is judged again, and is_judge_failure accepts a judge_unparseable event. Before, such a failure was recorded as judge_failed.
  • Environment validation checks materialized task rows. A row with task_id and task_input is validated the way rollout collection dispatches it: as MaterializedTask[SingleAgentTurnTaskInput] for single-agent-turn environment servers, and as an envelope check (valid TaskId, object task_input) for other servers or an unrouted taskset. Before, every row was validated as a flat BaseRunRequest. A prompt template on a materialized row is refused, since collection applies the template to the row's top level, which a task never reads.
  • observe_llm_judge_grading(..., judge_optional=True) for a grading that asks the judge only for some tasks. When no judge call was made, no judge operation is recorded and the grade is the verifier's own.

Why

Servers that grade with a judge only part of the time, or that serve typed task rows, hit these gaps: a judge that never produced a verdict was indistinguishable from an unreachable one, validation rejected valid task rows, and a judge-free grade was still recorded as an incomplete judge operation.

Compatibility

Existing servers are unaffected: JudgeError defaults to judge_failed, judge_optional defaults to false, and flat rows validate as before. Datasets that mix a prompt template with materialized task rows now fail validation with a clear message instead of failing later in collection.

Validation

  • uv run pytest tests/unit_tests/verification tests/unit_tests/environment tests/unit_tests/core tests/unit_tests/server_runtime tests/unit_tests/test_public_api.py: 3360 passed; 1 failure (test_process_projection_preserves_generated_sdk_details[cloudpickle]) and one uncollectable module are due to cloudpickle missing in the local env (the collection error also occurs on main).
  • ruff check, ruff format --check, and pre-commit hooks on the changed files pass.
  • Rollouts: N/A, no server behavior changes; covered by unit tests.

…terialized task rows, allow judge-optional grading

A parser-raised JudgeError can now carry failure_kind judge_unparseable (a judge that answered without a
valid verdict on every attempt). judge_failsafe masks it under that kind, still routed as judge_failed so
the saved answer is judged again, and is_judge_failure accepts a judge_unparseable event.

Environment validation checks a materialized task row (task_id and task_input) the way rollout collection
dispatches it: as MaterializedTask[SingleAgentTurnTaskInput] for single-agent-turn environment servers, and
as an envelope check for others. A prompt template on such a row is refused, since collection applies it to
the row's top level, which a task never reads.

observe_llm_judge_grading takes judge_optional for a grading that asks the judge only for some tasks: with
no judge call at all, no judge operation is recorded and the grade is the verifier's own.

Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer AdamRajfer self-assigned this Nov 13, 2026
@AdamRajfer AdamRajfer added feature New capabilities, enhancements, or enablement work area:core Shared APIs, servers, telemetry, health, and registries needs-review PR is ready for code review and waiting on a reviewer labels Nov 13, 2026
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 13, 2026 16:11

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

SHIP WITH CARE — four RISK findings.

The new judge failure kind doesn't survive the full recovery contract: collection changes the canonical sidecar class, but recovery still requires judge_failed. Optional grading can also erase an operation after a caught judge-call failure. The materialized-row validator has two gaps: malformed tasksets can raise an uncaught error, and invalid top-level rollout controls pass validation.

I inspected all six changed files and their directly affected routing, schema, observation, persistence, and recovery paths. This was a source-only review; I couldn't execute tests. The suggested changes and acceptance checks need verification before adoption.


Inline comments (escaped v1):

  • nemo_gym/eval/rollout_reverification.py line 1427: RISK — Keep collected judge_unparseable failures eligible for recovery.

    A verifier raising JudgeError("no verdict", failure_kind="judge_unparseable") now preserves its kind. However, collection persists _ng_failure_class="judge_unparseable" and _ng_failure_legacy_class="judge_failed", because the canonical class follows the failure kind. due_judge_failures() recognizes the legacy alias, but this binding excludes the row. Automatic re-judgment selects no saved answer, leaving the run incomplete even after the judge recovers. Previously, the failsafe normalized parser failures to judge_failed.

    Could you update selection and settlement together? In bind_judge_failures, replace the literal class comparison at both lines 1412 and 1427 with:

    matches_failure_class(row, JUDGE_FAILURE_KINDS)

    In the settlement predicates, replace the first condition of is_rejudgment_of with:

    (failure.get("_ng_failure_class") is None
     or matches_failure_class(failure, JUDGE_FAILURE_KINDS))

    In is_rejudgment_failure_of, replace both literal comparisons with matches_failure_class(failure, JUDGE_FAILURE_KINDS) and matches_failure_class(row, JUDGE_FAILURE_KINDS), respectively. Add the shared constant imports. Changing selection alone would leave successful settlement rejected. Preserve the answer, identity, finite-score, mask, predecessor, and admission checks; don't collapse the new kind back to judge_failed.

    Proposed acceptance checks, not executed: pass an actual unparseable failsafe response through collection into a manifest-backed store. Assert canonical judge_unparseable plus legacy judge_failed, then recover with a successful /verify reply: one verification, the unchanged saved answer and attempt, a selected score, no pending admission, and no remaining due failure. Cover failed re-judgment followed by success and spent-budget rejection. Retain the unchanged-answer/no-policy-call assertions in the existing recovery test, the provider-stop recovery cases, and rejection of changed answers or non-judge failures. Please verify the suggested changes before adopting them.

  • nemo_gym/server_runtime/verifier_observability.py line 128: RISK — Retain the operation after a caught judge-call failure.

    With judge_optional=True, let calculate() call call_judge(..., max_attempts=1), catch its connection, HTTP, or response-schema failure, and return a fallback grade. The call path updates dependencies and unidentified_calls only after HTTP and response-model parsing succeed. Both remain empty on failure, so this branch removes the operation even though the judge was asked. The operation should remain unknown, as it does with the default setting. Optional scorers that catch failures lose their incomplete grading-operation evidence. observe_verifier withholds a verifier-owned grading record because the model request was noted, but it doesn't restore this operation.

    Could you track attempted calls separately from received replies? Add calls_started: int = 0 to JudgeGrading, insert this at the beginning of call_judge._call() before the request, and add and not grading.calls_started to the removal condition:

    grading = _judge_grading.get()
    if grading is not None:
        grading.calls_started += 1

    Keep reply accounting unchanged. A failed attempt must not become an unidentified received reply, since a later successful retry must still be able to complete. Optional omission must require zero attempted judge calls, not merely zero parsed replies.

    Proposed acceptance checks, not executed: use the existing judge_server fixture with ConnectionError, catch the resulting failure inside calculate(), and return _result(0.0). Assert the grade is unchanged and one llm_judge operation remains unknown with empty dependencies. Through observe_verifier, assert no grading_record appears. Preserve genuinely judge-free optional omission, identified parsed-verdict completion, unidentified-reply unknown, and uncaught-failure propagation with outcome failed. Add a failed-then-successful retry case that still completes, and retain the existing rejected-reply accounting cases. Please verify the suggested change before adopting it.

  • nemo_gym/environment/validation.py line 774: RISK — Check the taskset type before using it as a dictionary key.

    With prompt_source="agent", {"task_id":{"taskset":[],"task_id":"1"},"task_input":{}} reaches this lookup and raises TypeError: unhashable type: 'list' before the validation handler runs. An object-valued taskset fails the same way. Malformed materialized datasets should instead raise EnvironmentValidationError naming the dataset, row, and task_id.taskset, as other malformed envelopes do.

    Could you replace this lookup with the following guard and leave the subsequent shared schema validation responsible for rejecting the identity?

        taskset = row["task_id"].get("taskset")
        environment_server = taskset_environment_servers.get(taskset) if isinstance(taskset, str) else None
    

    This retains typed validation for string tasksets routed to either single-agent-turn implementation, and envelope-only validation for custom servers or unrouted tasksets. The TaskId contract still rejects non-string, missing, and empty tasksets.

    Proposed acceptance checks, not executed: extend the broken-envelope test with taskset=[] and taskset={} under single-agent-turn, custom, and absent routes. Each must raise EnvironmentValidationError at task_id.taskset, not TypeError. Retain valid prepared-row acceptance for both single-agent-turn implementations and custom-server envelope acceptance. Please verify the suggestion before adopting it.

  • nemo_gym/environment/validation.py line 791: RISK — Validate the rollout controls carried beside a materialized task.

    The new branch validates only task_id and task_input, then skips BaseRunRequest. A valid routed task with top-level _ng_skip_token_capture: "true" or _ng_model_sampling: {"temperature": -1} therefore passes validate_environment(), although dispatch rejects it. These aren't discarded metadata: _episode_request_body forwards sampling and calls skips_token_capture, which rejects the string flag; the episode request's sampling model rejects the negative temperature. The flat branch still checks both through BaseRunRequest.

    Could you check these controls separately before reducing the row to its task envelope? Import model_sampling_from_run_body from the sampling module and skips_token_capture from episode context, then add this before envelope validation:

    try:
        model_sampling_from_run_body(row)
        skips_token_capture(row)
    except (ValueError, ValidationError) as error:
        raise EnvironmentValidationError(
            f"Dataset '{dataset.name}' row {line_number} has invalid rollout controls: {error}"
        ) from error

    The invariant is to preserve runtime validation of these top-level controls without requiring a top-level Responses request, which would reject valid custom-server tasks.

    Proposed acceptance checks, not executed: independently add each invalid control above to a valid materialized row and expect validation failure naming its dataset and row. Absent/null controls, boolean capture flags, and valid sampling values must still pass for single-agent-turn and custom-server rows. Retain custom tasks without responses_create_params, prepared-input checks, template rejection, and the existing flat-row error assertions. Please verify the suggested code before adopting it.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core Shared APIs, servers, telemetry, health, and registries feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants