Repository navigation
feat(eval): retry infra failures and make model failures final by one rule - #4844
AdamRajfer wants to merge 10 commits into
Conversation
… rule Resume retried every failure a server did not stamp terminal, so a model failure such as a malformed tool call got extra attempts. Each failure name now has a rule in `FAILURE_RULES`: a failure in a service the model does not control is retried; one caused by the model's output is final; a name that can be either is split by its cause; an unknown name without infra evidence is final. A server stamp can withhold a retry, never grant one. A final failure always counts as 0. With `require_complete`, final rows and rows at the attempt cap count as complete. GDPval's multistage orchestrator keeps its own retry policy. `error_message` is one of the text keys the rule reads, for harness rows written by older versions. Benchmark data gaps (`reference_missing`, `eval_missing`, `transport_ineligible`) are never retried, never counted, and complete. A run whose every rollout is settled (a data gap, or at the attempt cap) has no score but nothing left to retry, so it finishes instead of failing for a resume to rerun. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adam Rajfer <[email protected]>
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
/ok to test d402fe8 |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
HOLD — five RISK findings remain in retry classification and metric aggregation.
Inspected all nine changed files and traced the affected collection, standalone aggregation, reverification, environment adapters, Tau2 metrics, and GDPval orchestration paths. The GDPval multistage changes preserve its explicit-stamp retry policy. Validation was static only; no tests were executed.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
| return False | ||
| if record.get(NG_TERMINAL_KEY): | ||
| return True | ||
| return not is_retryable(_rule_kind(record), cause=failure_cause_of_row(record)) |
There was a problem hiding this comment.
RISK — Preserve retry evidence on the flat environment adapter path.
Failure / blast radius: An empty TimeoutError() during a dependency call becomes an unstamped environment_server_failed row with an empty message through SingleAgentTurnLegacyEnvironmentServer._legacy_result. That adapter drops the cause, and the collector reads response-header causes only for materialized rows. The new rule therefore labels this infrastructure timeout model-caused, scores it zero, and permanently gates resume. This affects flat-row pairings, including the default GDPval adapter; base retried the unstamped row.
Correction / preservation: Carry the live HandledEpisodeError.cause through run_legacy and consume that trusted header for flat failure rows as well as native episodes. For historical adapter rows lacking a cause, preserve retryability when their stage proves an admission/seed/cleanup infrastructure failure. Do not make every unstamped environment failure retryable: an agent parse failure explicitly marked model must remain final. The exact adapter plumbing needs verification; changing this predicate alone cannot recover discarded evidence.
Acceptance — proposed, not run: Exercise the real flat adapter with an agent dependency TimeoutError() and with a resources seed timeout: each sidecar row must retain infra, remain outside default metrics, and dispatch on resume. Repeat through the native episode path. A malformed-tool-call 500 carrying model must score zero and not resume; explicit terminal stamps must still gate.
There was a problem hiding this comment.
Fixed in 9bcd32f (fix(rollout): keep the live failure cause on the flat environment adapter's rows), with a test that fails without the fix.
| for key, row in latest_by_key.items() | ||
| if key not in scored_keys and row.get(NG_FAILURE_CLASS_KEY) in wanted | ||
| if key not in scored_keys | ||
| and _counts_failure_class(row, failure_classes, retry_terminal_timeouts=retry_terminal_timeouts) |
There was a problem hiding this comment.
RISK — Make Tau2's metrics hook accept the failures now counted automatically.
Failure / blast radius: A real malformed-tool-call response from Tau2Agent._failure_response has reward zero but no result. This change now sends it to /aggregate_metrics even with the default empty class selection. Tau2Agent.compute_metrics unconditionally reads task["result"]["termination_reason"], raising KeyError; collection and standalone aggregation fail instead of reporting the final zero. An all-failure run also has zero assistant messages, exposing the division at line 555.
Correction / preservation: Update Tau2Agent.compute_metrics alongside this automatic inclusion: count failure rewards in domain, subtask, macro-average and sample denominators, but read trajectory diagnostics only when a real simulation result exists. Guard zero-message diagnostic denominators. Do not fabricate messages or remove failures from the reward denominator. Preserve successful trajectory diagnostics and max-agent-step termination accounting. A one-line collector patch is insufficient because the benchmark owns this metric contract.
Acceptance — proposed, not run: Feed one real success of reward 1 and one _failure_response of reward 0 from the same domain through the real aggregation hook: HTTP 200, mean/reward and domain reward 0.5. An all-malformed run must aggregate to zero without division errors. Retain the exact success metrics in test_compute_metrics and the max-agent-step count/pct assertions immediately following it.
| # With nothing to score and nothing to count, only the coverage report keys rollouts, and an | ||
| # agent's name does for that: the head server is reached for scoring alone. | ||
| if not (results or config.count_failure_classes_as_zero or config.count_missing_rollouts_as_zero): | ||
| if not (results or config.count_failure_classes_as_zero != [] or config.count_missing_rollouts_as_zero): |
There was a problem hiding this comment.
RISK — Resolve server identity when final failures are the only metric inputs.
Failure / blast radius: With empty main shards and default count_failure_classes_as_zero=[], servers_by_agent() returns {} even though final sidecar rows are now scored. Aggregate two attempts of (task=0, rollout=0) for the same environment: an older failure naming only agent_ref, and a newer failure also stamped _ng_environment_server. Their identities become (agent,0,0) and (server,0,0), so both survive. _call_aggregate_metrics then routes both to the same server, where RewardProfiler rejects duplicate rollout keys. Before automatic final inclusion there was nothing to score under these defaults.
Correction / preservation: Remove the config-only early return. Resolve the mapping lazily when group(row) needs it for any row that _counts_failure_class will score; use one consistent mapping throughout failure deduplication and task-field filling. Retain the offline, no-head-server behavior when every row is an unselected retryable failure, and keep separate environment servers distinct even if they front the same agent. This needs selection-aware resolution, not an unconditional head-server connection.
Acceptance — proposed, not run: With agent_a -> env_a, an older agent-only final failure and a newer env-stamped final failure for the same key must yield exactly one zero and successful aggregation under default selection. Two different server stamps must yield separate zeros. Preserve test_a_run_with_nothing_to_score_does_not_need_the_head_server: its retryable-only input must still return None without connecting.
There was a problem hiding this comment.
Fixed in f569cad (fix(eval): tell environment servers apart when only final failures are scored), with a test that fails without the fix.
| return False | ||
| if record.get(NG_TERMINAL_KEY): | ||
| return True | ||
| return not is_retryable(_rule_kind(record), cause=failure_cause_of_row(record)) |
There was a problem hiding this comment.
RISK — Apply the final-zero contract to reverification metrics too.
Failure / blast radius: The new predicate is also used by reverification's resume cache, but reverification still aggregates only its main JSONL. If two /verify replies are a reward-1 success and an unstamped verifier_error without infra evidence, the second is now final and cannot be retried, yet the reported mean remains 1 instead of 0.5. Running gym eval aggregate over those same artifacts includes the zero and gives a different score.
Correction / preservation: Before reverification's _call_aggregate_metrics, include metrics-only copies of the latest final sidecar failures using the shared selection logic, exclude successful keys, honor retry_terminal_timeouts, and build aligned routing rows for the added records. Keep sidecar contents, rollout exports, and returned persisted-success rows unchanged. Unstamped infra failures must remain retryable and omitted; data gaps must remain unscored. The existing routing projection means this is not safely fixed by appending to results alone.
Acceptance — proposed, not run: Mock two verifier replies as above, retaining real final selection and aggregation: expect mean 0.5 both initially and on a no-dispatch resume. Standalone aggregation must agree. Replace the failure with judge_failed: expect only the success in metrics and the failed key eligible for retry. Replace it with reference_missing: expect exclusion and no retry. Preserve the output-routing test's artifact and return-value assertions.
There was a problem hiding this comment.
Not changed in this PR, on purpose. Reverification never counted sidecar failures, on main either, so this is a scope question rather than a regression: should reverification count final failures as 0, as gym eval aggregate does, or stay a re-judge view with gym eval aggregate as the score of record? That decision is open; we'll follow up in this thread.
| for key, row in latest_by_key.items() | ||
| if key not in scored_keys and row.get(NG_FAILURE_CLASS_KEY) in wanted | ||
| if key not in scored_keys | ||
| and _counts_failure_class(row, failure_classes, retry_terminal_timeouts=retry_terminal_timeouts) |
There was a problem hiding this comment.
RISK — Force final failures to zero rather than retaining partial rewards.
Failure / blast radius: Automatic final selection now reaches _counted_failure_row, which uses setdefault("reward", 0.0). A persisted row such as {"_ng_failure_class":"agent_run_error","_ng_failure_cause":"model","reward":0.8} is final but contributes 0.8, contradicting the new final-zero contract. With one reward-1 success, the mean becomes 0.9 rather than 0.5 in both collection and standalone aggregation.
Correction / preservation: Pass the effective terminal decision into _counted_failure_row and replace its reward assignment with scored["reward"] = 0.0 if final else row.get("reward", 0.0). Both callers must compute final using the same timeout-retry setting used for selection. Keep existing rewards for explicitly selected retryable failures; keep missing rewards zero, data gaps excluded, and all persisted artifacts untouched. The conditional implementation is important: a blanket reward overwrite changes the existing opt-in contract.
Acceptance — proposed, not run: A final model row carrying reward 0.8 must produce a metrics-only reward of 0.0 even with selection []; an explicitly selected infra row carrying 0.8 must retain 0.8. A timeout opted into retries must follow the retryable case. Data gaps must produce no metric row. Verify the original sidecar bytes are unchanged and retain the latest-attempt/success-suppression assertions in test_failure_rows_counted_as_zero_selects_the_last_attempt_of_each_rollout.
There was a problem hiding this comment.
Fixed in 8ccbaa3 (fix(eval): count a final failure as 0 even when its row carries a reward), with a test that fails without the fix.
Bot finding 4338966629, PR NVIDIA-NeMo#4844 (part 2, retry rule); the Tau2 metrics live in part 7. Final failures now reach /aggregate_metrics by default. A rollout without a result was already handled; a run with no assistant message at all still divided by zero in messages_with_incomplete_reasoning/pct. The denominator is at least 1, so that rate is 0 there. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adam Rajfer <[email protected]>
…pter's rows Bot finding 4338966618, PR NVIDIA-NeMo#4844 (part 2, retry rule). The flat single_agent_turn_legacy adapter turns a handled episode failure into a flat sidecar row and dropped the cause the server read from the live error. An empty TimeoutError() then left no evidence in the row, the rule placed it as the model's, and resume never retried it; main retried such an unstamped row. The adapter now puts that cause on the row, as the response header carries it for episode replies. run_request resets the cause per request. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adam Rajfer <[email protected]>
Bot finding 4338966661, PR NVIDIA-NeMo#4844 (part 2, retry rule). A final failure is always counted as 0, but the metrics-only copy kept a reward the row already carried, so a final model failure with reward 0.8 lifted the score. Both gym eval run and gym eval aggregate now zero it, judged with the same timeout setting as the selection. A retryable row a caller selects explicitly keeps its reward, as before; the sidecar is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adam Rajfer <[email protected]>
…e scored Bot finding 4338966642, PR NVIDIA-NeMo#4844 (part 2, retry rule). gym eval aggregate skipped the server lookup when nothing was selected for scoring, but final failures are scored whatever the selection. Two attempts of one rollout in different shards, one naming only its agent and one also its environment server, then got different identities, both were sent to the same server, and aggregation failed on the duplicate key. The lookup now also runs when a sidecar holds a final failure; with only retryable failures the offline path still needs no head server. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adam Rajfer <[email protected]>
Review finding 4338966652 (follow-up to NVIDIA-NeMo#4844). Reverification already treats a final sidecar failure as final for its resume, but its metrics read only the main rollouts file, so a run with one success and one final verifier failure scored 1.0 there and 0.5 in gym eval aggregate. Reverification now adds metrics-only zeros for the final failures, chosen by the same selection gym eval aggregate uses with no retryable class (a key that succeeded is skipped, retry_terminal_timeouts is honoured). Retryable failures and data gaps stay out of the score; the sidecar, the exports and the returned rows are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adam Rajfer <[email protected]>
This reverts commit f82c313. Retrying an unparseable judge verdict changes the reward that servers such as math_with_judge return in training too, and this part has no evaluation-mode switch. The change will come back in a later part, limited to evaluation. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adam Rajfer <[email protected]>
Part 2 (NVIDIA-NeMo#4844), the retry rule, with the spent-budget fix. A 404 from the policy or the judge (a model that is not deployed, a wrong route) is a deployment or config error, but every 404 was read as the model's own request, so the rollout became a final 0. A 404 is now infra when it answers a call to a model server's API route (/v1/responses, /v1/chat/completions, /v1/completions, /v1/messages, /v1/embeddings), on the live error and on its relayed text. 404 is not added to the infra statuses: other 404s keep their label, and a sandbox exec 404, which the sandbox rule decides, is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adam Rajfer <[email protected]>
Part 2 (NVIDIA-NeMo#4844), the retry rule, with the spent-budget fix. A provider can reject a malformed authorization header or an invalid, incorrect or missing API key with a 400 rather than a 401, so on the policy endpoint every rollout became the model's final 0. A 4xx whose reason or body names a broken credential, or an access denial (requires approved access), is now infra and retried, on the live error and on its relayed text, on any endpoint. Other 400s keep their label. The cause is a label read by evaluation's retry rule; the one consumer that changes a row from it, the verifiers agent's outage mask, applies only in evaluation. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adam Rajfer <[email protected]>
test_a_sandbox_exec_404_is_unchanged imported the opensandbox SDK unconditionally, so it failed where the optional sandbox extra is not installed. The relayed-text check now always runs, and the live-exception check skips through pytest.importorskip when the SDK is missing. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adam Rajfer <[email protected]>
Part 2 of 9, merge in order. Stacked on #4843; the diff shows only this part's changes.
What and why. Resume retried every failure a server did not stamp terminal, so a model failure such as a malformed tool call got extra attempts. Each failure name now has a rule in
FAILURE_RULES: a failure in a service the model does not control is retried; one caused by the model's output is final; a name that can be either is split by its cause; an unknown name without infra evidence is final. A budget or quota error from any HTTP endpoint (a 402, or a 4xx whose reason or body says the budget or quota is spent, such as a 422 "Budget has been exceeded" orinsufficient_quota), or failure text that says so, is infra: an account limit, not the model's output, so it is retried. A 404 from a model or judge route is infra too: a missing model or a wrong route is a deployment error, not the model's output. A 404 from a sandbox exec keeps its label. A broken credential is infra on any endpoint: a 4xx whose reason or body names a malformed authorization, an invalid, incorrect or missing API key, or access that requires approval. On a policy endpoint it would otherwise be a final 0 for every rollout. A server stamp can withhold a retry, never grant one. A final failure always counts as 0 ingym eval runandgym eval aggregate, even when its row carries a reward. Reverification metrics still cover only the rows it re-verified. Withrequire_complete, final rows and rows at the attempt cap count as complete. Final failures are scored whatever+count_failure_classes_as_zeroselects, sogym eval aggregatelooks up the environment servers whenever a sidecar holds one. Two attempts of one rollout in different shards still count as one 0. GDPval's multistage orchestrator keeps its own retry policy.error_messageis one of the text keys the rule reads, for harness rows written by older versions. The flatsingle_agent_turn_legacyadapter has no response header, so it puts the cause its server read from the live error on the failure row as_ng_failure_cause. Benchmark data gaps (reference_missing,eval_missing,transport_ineligible) are never retried, never counted, and complete. A run whose every rollout is settled (a data gap, or at the attempt cap) has no score but nothing left to retry, so it finishes instead of failing for a resume to rerun.Judge failures. This part reads a judge error's cause like any other failure's. What a judge failure becomes in evaluation is finalised in #4851: the judge is retried in place on the same answer, and the rollout is never re-dispatched for it.
Methodology. A failure caused by the model's output is the model's result and scores 0; a failure of the evaluation's own infrastructure is not a measurement and is retried. A task that runs out of its own time budget (
timeout_exceeded, an agent's ownasyncio.timeout) is the model's, as Terminal-Bench scores an agent timeout. A task the benchmark cannot score for lack of its own data is left out.Eval scores. Runs with no failed and no missing rollouts do not move. Runs with final model failures move down, since those count as 0 and are no longer retried. Benchmarks with data-gap rows do not count them.
Training and RL: no change. The rule is applied by
is_terminal_failure, scoring and completion checks insidegym eval run,gym eval aggregateand reverification.run_examplesdoes not call any of them, and GDPval multistage reads only the explicit stamp, as before. Checked by code reading and byresources_servers/gdpval/tests/test_multistage_orchestrator.pypassing unchanged.Unit tests.
test_failure_retry_rule.py(rule per kind, legacy_agent relay, resume, harness exits,test_a_spent_budget_or_quota_is_infra,test_other_4xx_keep_their_label,test_a_404_from_a_model_or_judge_route_is_infra,test_a_sandbox_exec_404_is_unchanged,test_a_broken_credential_is_infra_on_any_endpoint),test_failure_retry_rule_evidence.py(completion, Terminal-Bench rows, harness rows inerror_message, data gaps,test_a_task_that_ran_out_of_its_own_time_budget_is_a_final_zero,test_a_run_with_nothing_left_to_retry_finishes), updatedtest_rollout_collection.pyandtest_rollout_reverification.py,environment_servers/single_agent_turn_legacy/tests/test_app.py(a flat failure row keeps the cause read from the live error);scripts/harness_conformance/tests/test_runner.pyexpects a harness's own 422 to finish as a final 0.🤖 Generated with Claude Code