Repository navigation
feat(verification): keep a judge's unparseable verdict kind, check materialized task rows, allow judge-optional grading - #6145
AdamRajfer wants to merge 2 commits into
Conversation
…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]>
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
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.pyline 1427: RISK — Keep collectedjudge_unparseablefailures 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 tojudge_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_ofwith:(failure.get("_ng_failure_class") is None or matches_failure_class(failure, JUDGE_FAILURE_KINDS))
In
is_rejudgment_failure_of, replace both literal comparisons withmatches_failure_class(failure, JUDGE_FAILURE_KINDS)andmatches_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 tojudge_failed.Proposed acceptance checks, not executed: pass an actual unparseable failsafe response through collection into a manifest-backed store. Assert canonical
judge_unparseableplus legacyjudge_failed, then recover with a successful/verifyreply: 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.pyline 128: RISK — Retain the operation after a caught judge-call failure.With
judge_optional=True, letcalculate()callcall_judge(..., max_attempts=1), catch its connection, HTTP, or response-schema failure, and return a fallback grade. The call path updatesdependenciesandunidentified_callsonly 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 remainunknown, as it does with the default setting. Optional scorers that catch failures lose their incomplete grading-operation evidence.observe_verifierwithholds 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 = 0to JudgeGrading, insert this at the beginning ofcall_judge._call()before the request, and addand not grading.calls_startedto 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_serverfixture withConnectionError, catch the resulting failure insidecalculate(), and return_result(0.0). Assert the grade is unchanged and onellm_judgeoperation remainsunknownwith empty dependencies. Throughobserve_verifier, assert nograding_recordappears. Preserve genuinely judge-free optional omission, identified parsed-verdict completion, unidentified-replyunknown, and uncaught-failure propagation with outcomefailed. 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.pyline 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 raisesTypeError: unhashable type: 'list'before the validation handler runs. An object-valued taskset fails the same way. Malformed materialized datasets should instead raiseEnvironmentValidationErrornaming the dataset, row, andtask_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 NoneThis 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=[]andtaskset={}under single-agent-turn, custom, and absent routes. Each must raiseEnvironmentValidationErrorattask_id.taskset, notTypeError. 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.pyline 791: RISK — Validate the rollout controls carried beside a materialized task.The new branch validates only
task_idandtask_input, then skipsBaseRunRequest. A valid routed task with top-level_ng_skip_token_capture: "true"or_ng_model_sampling: {"temperature": -1}therefore passesvalidate_environment(), although dispatch rejects it. These aren't discarded metadata:_episode_request_bodyforwards sampling and callsskips_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_bodyfrom the sampling module andskips_token_capturefrom 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.
Signed-off-by: Adam Rajfer <[email protected]>
What
Three small, independent changes to shared verification and validation code:
JudgeErrorraised by a parser can carryfailure_kind="judge_unparseable"(a judge that answered without a valid verdict on every attempt).judge_failsafemasks the row under that kind, still routed asjudge_failedso the saved answer is judged again, andis_judge_failureaccepts ajudge_unparseableevent. Before, such a failure was recorded asjudge_failed.task_idandtask_inputis validated the way rollout collection dispatches it: asMaterializedTask[SingleAgentTurnTaskInput]for single-agent-turn environment servers, and as an envelope check (validTaskId, objecttask_input) for other servers or an unrouted taskset. Before, every row was validated as a flatBaseRunRequest. 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:
JudgeErrordefaults tojudge_failed,judge_optionaldefaults 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 tocloudpicklemissing in the local env (the collection error also occurs onmain).ruff check,ruff format --check, and pre-commit hooks on the changed files pass.