Repository navigation
feat: record rollouts that were scored despite a failure - #6393
Conversation
Part of #2750. Several servers swallow a failure and return a normal result, so the rollout is scored from a degraded path and cannot be told from one that was graded normally: a harness crash scored 0, a judge that did not answer and fell back to a default reward, a step limit that ended the run, a verifier whose sandbox could not run. Nothing changes about how these are scored. This records them. - observe_scored_despite_failure (nemo_gym.core) records an event with the operation scored_despite_failure in the request's failure log, so it travels with the reply and is saved beside the row. It sets no failure_id and changes no reward, response, retry or exit code. - The rollout_scored_despite_failure health check counts those events, so the run's health summary reports them by failure kind. Other saved events, such as recovered model attempts, are not counted. It can be left out with --health-check-ignore. - The Environment Server records an agent reply that says failed without a classified outcome, which it verifies as before. This covers every agent that does not classify its failures. - Agents record the failure they swallow: finance_agent, harbor_agent, mini_swe_agent, mini_swe_agent_2 (a crash scored 0), toolsandbox_agent (a model error that ends the run), and simple_agent, simple_agent_with_compaction and cvdp_agent (a step limit). - Verifiers record what they swallow: over_refusal_detection and jailbreak_detection (a judge that did not answer), bigcodebench, math_formal_lean and swerl_gen (a harness that could not run). - The collector records a /run that dropped after it may have been delivered and was resent. - gym eval status shows the state and error of each post-run export, which it ignored. The W&B run is closed as failed when delivery or the evaluation failed, as the MLflow run is. The GitLab dataset download raises on an HTTP error instead of saving the error page as the dataset. Reverification says when it leaves out a kill-shaped result. Signed-off-by: Onur Yilmaz <[email protected]>
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE
I found seven RISK issues. Recovered CVDP attempts can falsely mark the final rollout unhealthy, while checkpoint replay, cached results and some runner failures lose the new diagnostics. Uncapped collection retries and failed post-run W&B uploads also bypass their new reporting paths.
I inspected all 44 changed files and traced the affected persistence, retry and health-check contracts. I did not execute tests in this read-only review.
Inline comments (escaped v1):
-
responses_api_agents/cvdp_agent/app.pyline 430: RISK: Mark only the CVDP attempt that supplies the scored result.With
simple_agent=True,max_steps=1and parse retries enabled, let the first reply contain reasoning text that cannot be parsed as RTL, then let the next attempt return valid RTL. The first invocation records this limit, but_run_simple()discards its verification result and retries. The HTTP client has already merged that reply's events into the outer request log. The completed final rollout therefore retainsscored_despite_failure: agent_limit, so the new health check falsely counts it toward the unhealthy fraction.Could you coordinate
responses()and_run_simple()so only the terminal scored attempt contributes this marker? Discarded attempts should remain ordinary recovered diagnostics. The implementation needs care because reply reports are merged before the retry decision; moving this into optional trajectory processing would also miss capture-disabled runs.Preserve markers for terminal capped attempts and direct capped
/v1/responsescalls. Keep parse-retry decisions, final output/reward and aggregate usage unchanged.Proposed checks, not executed: extend the existing recovered-limit case with request-failure middleware and actual reply-header propagation. With capture both enabled and disabled, assert that recovery keeps the final output/reward and produces no scored-despite-limit event. Retain both call references when captured. Assert one marker for an exhausted terminal cap and a direct capped invocation, and none for immediate completion.
-
responses_api_agents/simple_agent/app.pyline 981: RISK: Save the limit report with Simple Agent's replayed reply.The new limit event lives only in the current
RequestFailureLog. With checkpointing enabled, finish a capped activation, then repeat its activation index after losing the first reply.responses()returns_saved_reply()without rerunning the loop. This saved state contains only response/cookies, and_saved_reply()restores no report. The same capped output then reaches collection without its marker. The legacy/runverify/return boundaries also omit this request-local evidence.Could you persist and replay the observed report with the completed reply, including
_dump_reply()and checkpoint restore, and carry it through the legacy boundaries after the loop finishes? Restore event IDs without selecting afailure_id; do not create a new event on each replay. This spans persistence contracts, so a one-line observer change is insufficient.Preserve exactly-once execution, cookies and trajectory observations. Successful replays must stay marker-free, and existing classified failure reports must stay intact.
Proposed checks, not executed: adapt the completed-activation replay test to return a tool call at
max_steps=1, with failure middleware installed. Original and replayed replies must carry the same singleagent_limitevent without another model/tool call. Repeat after checkpoint export/restore and for legacy runs restored atverifyandreturn. Retain the existing successful-replay assertions. -
environment_servers/single_agent_turn/app.pyline 434: RISK: Carry the fallback event through a return-stage checkpoint.If an unclassified failed agent reply is verified and the episode is checkpointed at
next="return"before collection receives it, the replacement returns the saved reward without the new event. The observation exists only inRequestFailureLog; this boundary saves result/trajectory data but not that log. Restoringstage="return"skips the observation branch, so the degraded result loses its health marker independently of whether the agent itself supports reply replay.Could you save the diagnostic report separately in the boundary continuation and restore it into the replacement request's log with
add_saved? Keep it outside the ordinaryresult, because collection rejects reserved diagnostic keys there. Keep the original event ID, reward and classified-outcome policy; restoring observations must not select a rolloutfailure_id.Proposed check, not executed: return an unclassified failed agent response, complete verification, export a checkpoint parked at
next="return", then restore into a fresh request capture. Assert that verification is not repeated, the reward is unchanged, and the final reply carries exactly the original scored-despite-failure event without a selected failure. Retain the completed and classified reply cases, which must not gain this fallback marker. -
responses_api_agents/mini_swe_agent_2/app.pyline 870: RISK: Keep crash diagnostics when returning cached mini-SWE results.Set
skip_if_exists=True, let the harness raise, then request the same instance again. The new observer records an event only on the first request. The cache write serializes no failure report, so this cache-hit return produces the same zero/empty output without a marker.mini_swe_agenthas the same gap between its new crash observation and persisted response. Cached crash results therefore still bypass the new health check.Could you save the observed report alongside each cached crash result and restore it into request observations on a cache hit in both implementations? Choose the cache and transport representation together, keeping event identity stable and
failure_idunset.Preserve the cache policy: hits must not rerun the harness or change reward/output. A normally evaluated unresolved result scoring zero must not acquire a crash marker. Keep older cache files readable; do not infer failure from zero reward alone.
Proposed checks, not executed: extend each agent's
test_run_failed_executionwith a temporary results directory and a second request in a fresh failure-log scope. Assert that the second request invokes no harness and exposes the same singleagent_run_errorscored-despite-failure event while keeping zero reward/empty output. Repeat with a valid unresolved result and expect no marker. Load an older cache file without diagnostics successfully. -
resources_servers/bigcodebench/app.pyline 172: RISK: Record the runner's explicit JSON error result.The checked-in runner catches exceptions, including a failed
bigcodebench.evalimport, and prints{"status":"error","details":{"traceback":"..."}}. This return accepts that valid JSON without either new observation, andverify()scores it zero. The runner's normal error protocol therefore still leaves ungraded results without the health marker.Could you inspect the decoded result before returning it? A small replacement for this return is:
result = json.loads(stdout.decode("utf-8", errors="replace")) if isinstance(result, dict) and result.get("status") == "error": observe_scored_despite_failure( boundary=FailureBoundary.RESOURCES_SERVER, failure_kind=VERIFIER_ERROR, failure_reason="The bigcodebench runner returned an error: " + str(result.get("details") or {})[:500], stage="verification", ) return result
Keep the outer-timeout and invalid-JSON observations. Preserve graded solution results:
pass,fail, the runner's solutiontimeout, and its documented null timeout status must return unchanged without this marker.Proposed checks, not executed: extend TestRunnerFailuresAreRecorded with a subprocess printing the JSON error above. Assert an unchanged result, one
verifier_errorscored-despite-failure event, and no selectedfailure_id. Retain the timeout/invalid-JSON cases and add null to the no-marker cases. Verify the suggested code before adopting it. -
nemo_gym/rollouts/rollout_collection.pyline 5639: RISK: Observe transport retries independently of the optional attempt bound.run_examples(..., record_output_dir=..., record_shard=...)can resend a dropped/run, but itsattempt_errorsstays empty. This callback is installed only when_max_num_triesis set, and the public shard-recording path passes no bound. A successful resend is consequently saved without the new warning that the episode may have run twice. The added collection test usesrun_from_config, which does pass a bound.Could you move the callback out of the conditional dictionary at this
server_client.postcall?_on_transport_failure=lambda error, _: attempt_errors.append(error), **( {"_max_num_tries": _max_num_tries, "_retry_other_errors": False} if _max_num_tries is not None else {} ),
This lets the existing report merge and shard writer save the observation without changing retry limits or decisions. Keep refused connections and connection timeouts excluded, preserve events from the successful reply, and leave raw caller-facing results unchanged.
Proposed check, not executed: record a shard through
run_exampleswith default retry settings, simulateServerDisconnectedErrorfollowed by success, and assert unchanged reward plus onetransport_peer_dropscored-despite-failure event and no selectedfailure_idin the saved row. Repeat with a refused connection, a connection timeout and no retry; none should add this marker. Include an existing reply event and assert it survives the merge. Verify the suggested code before adopting it. -
nemo_gym/artifacts/exporters/wandb.pyline 74: RISK: Include failed post-run uploads in the failed-finish condition.During a post-run export, make
run.config.updateorrun.lograise.BaseExporter.export()calls the unguarded logging hooks insidewith self, so_guard()never sets_delivery_failed.__exit__()ignores the exception and calls this teardown with both flags false. It therefore callsfinish()rather thanfinish(exit_code=1), even though the export subsequently returnsFAILED. The new condition covers guarded live delivery failures but misses post-run delivery failures.Could you mark an exceptional export context as failed before teardown? The shared context manager can keep its existing exception propagation while supplying the missing fact:
def __exit__(self, exc_type, exc_value, traceback) -> None: if exc_type is not None: self._delivery_failed = True self.teardown()
Preserve normal post-run completion, live
_guardfailures andmark_run_failed()handling. Failed exports must still return their error and write no completion receipt; teardown must not suppress the original exception. The shared change also applies to MLflow's existing failure condition.Proposed checks, not executed: extend the W&B post-run export test with config, metrics and rollout-upload exceptions. Expect
ExportState.FAILED, no receipt andfinish(exit_code=1). Keep the successful export's no-argumentfinish()and receipt assertions, plus the new live/evaluation failure tests. Verify the suggested code before adopting it.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
…resends Address review of the visibility change: - record bigcodebench runner error results - observe resent /run attempts without an attempt bound - fail a W&B/MLflow export that raises after setup - save events with cached mini-swe results, return-stage checkpoints and Simple Agent replayed replies and legacy boundaries - keep a discarded CVDP attempt's limit event as a diagnostic Signed-off-by: Onur Yilmaz <[email protected]>
|
/review reset=true |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE
I found three RISK issues in diagnostic coverage. Earlier checkpoints can lose an agent's event, while recovered Lean verification can falsely mark the final result unhealthy. Harbor's default harness also swallows crashes below the added observer.
I verified the code changes addressing all seven prior findings. This was a fresh review of all 47 changed files, including their affected persistence, retry and health-check paths. I did not execute tests in this read-only review.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
| The error result the caller gets is unchanged and is scored as before. A compile that the sandbox itself reports as | ||
| timed out comes back as a normal result; only a failure to get any answer is recorded here. | ||
| """ | ||
| observe_scored_despite_failure( |
There was a problem hiding this comment.
RISK: Downgrade the Lean marker when refinement discards that attempt.
With the checked-in multi-turn configuration, let the first sandbox call return HTTP 502 and the next compile return process_status="completed". This helper marks the first /verify reply. The HTTP client merges its events into the outer request, but the refinement loop returns only the final verification result without downgrading the earlier marker. Reward is correctly 1, but the recovered failure still counts against --max-unhealthy-fraction.
Could you coordinate this producer with ProofRefinementAgent.run()? Add RequestFailureLog to that module's core imports and snapshot events immediately before its /verify call:
failure_log = RequestFailureLog.current()
known_events = set(failure_log.report.events) if failure_log is not None else set()After all terminal-exit guards for needs_correction, remaining turns and the correction prompt, before preparing another turn, add:
if failure_log is not None:
failure_log.discard_scored_despite_failures(known_events)Verify this suggestion before adopting it. Only the verification result used for the final score should contribute this marker; discarded verification failures should stay diagnostic. Keep markers for direct failed /verify calls and terminal sandbox failures, including exhausted correction turns. Keep genuine compiler failures and sandbox-reported proof timeouts marker-free. Preserve final reward, summed usage, correction prompts and all_attempts.
Proposed checks, not executed: extend the two-turn refinement test with failure middleware and reply-header propagation. For 502 followed by a completed compile, assert reward 1, both attempts, unchanged summed usage, one discarded_attempt diagnostic and no scored_despite_failure event. Repeat with capture disabled. For two sandbox failures with one correction turn, expect one discarded event and one terminal marker, without a selected failure_id. Retain the direct-failure and genuine compile-result assertions.
There was a problem hiding this comment.
Fixed in 44ae8d0. proof_refinement_agent now downgrades what a verification turn swallowed to an ordinary diagnostic when the next correction turn replaces that turn's result, the same way the CVDP retry does. The final marker then reflects only the turn that is scored. Covered by a test where the first turn is marked and the second recovers (no marker left) and one where the scored turn is marked too (marker kept).
| except Exception as e: | ||
| print(f"Error running Harbor job: {e}") | ||
| # The reward stays 0; the rollout is recorded as scored despite the failed Harbor job. | ||
| observe_scored_despite_failure( |
There was a problem hiding this comment.
RISK: Carry the default Harbor harness's swallowed errors back to the request.
The new observer misses crashes caught inside the configured harness. The default configuration uses Terminus2NemoGym, whose run() catches unexpected exceptions and returns normally. For example, make its parent run() raise RuntimeError("harness crashed") after one completed turn. That catch deliberately lets Harbor verify the partial trajectory. HarborAgent.run() then returns the verifier reward with a completed response, without reaching this observer. The saved flags contain only memory/context-limit booleans, so the server cannot recover the error. The swallowing behavior predates this PR, but these degraded results still bypass its new reporting path.
Could you persist unexpected terminal harness-error evidence alongside the trial artifacts and have HarborAgent.run() observe it after reading them? This code runs the harness in a Ray worker, so calling the request-local observer there alone will not carry the event back. The invariant is that a swallowed unexpected harness error follows its scored result into the server request. The persisted representation needs to be chosen before I can suggest a complete patch.
Keep the partial trajectory, verifier reward, usage and existing memory/context flags unchanged. Do not infer a crash from zero reward or classify ordinary unresolved results and model context exhaustion as unexpected harness crashes. Keep the outer-exception marker added here.
Proposed checks, not executed: make the parent harness raise the runtime error above, retain a partial trajectory and verifier result, and pass those artifacts through HarborAgent.run() in a fresh RequestFailureLog scope. Assert unchanged output/reward and exactly one agent_run_error event with operation scored_despite_failure, without a selected failure_id. A normal unresolved result and a recovered internal retry must add no such marker. Retain the outer-crash assertions in test_run_failed_execution and the existing context/memory-limit behavior.
There was a problem hiding this comment.
Fixed in 162156c. Terminus2NemoGym.run() still catches the crash so the trial reaches the verifier, but it now writes it to agent_error_flags.json, and the Harbor server records the rollout as scored despite it. The verifier's reward is unchanged, and a context-length failure keeps its own flag and is not recorded as a crash. Tests cover the harness writing the flag and the server recording it, or not, for crashed, clean, context-length and missing-flags cases.
yuhezhang-ai
left a comment
There was a problem hiding this comment.
Thanks for making these failure paths visible. I would address the loss of diagnostics at the earlier single_agent_turn checkpoints before merging; I added reproduced evidence to the existing checkpoint thread.
The three new inline comments are nonblocking: preserve a compact warning when diagnostics overflow, document/test the delivery-classification change for unbounded callers, and share export-layout constants.
Validation included focused unit tests and protocol/checkpoint reproductions. Missing optional dependencies limited some exporter/server checks, and no real-model rollouts were run.
Signed-off-by: Onur Yilmaz <[email protected]>
…ose_agent and verify checkpoints A replacement restored at close_agent or verify skipped the agent call, so the events its reply carried (for example agent_limit) were lost and the capped result was verified and collected without its marker. Save the observed report at both boundaries and restore it, as the return boundary already did. The unclassified-failure event is written before the verify boundary, so a restore at verify does not observe it again. Signed-off-by: Onur Yilmaz <[email protected]>
…urn that a correction turn replaces A turn whose verifier could not reach its sandbox marks the request through the reply the HTTP client merges. When the next correction turn recovers, the final result is healthy, so the earlier turn's marker is kept as an ordinary diagnostic instead of marking the scored result. Signed-off-by: Onur Yilmaz <[email protected]>
…the verifier runs Terminus2NemoGym.run() catches an unexpected exception so the trial can still be verified. The crash now goes into the agent error flags file, and the server records the rollout as scored despite it. The verifier's reward and the context-length and memory-limit handling are unchanged. Signed-off-by: Onur Yilmaz <[email protected]>
…t step and eval status can import them gym eval status spelled the artifacts and exports directory names and the result suffix itself, because it may not import orchestration, and a test searched its source for the quoted tuple. The names now live in nemo_gym.artifacts.run_files, which orchestration and the CLI both import, so the duplicated invariant and the source-text test are gone. Signed-off-by: Onur Yilmaz <[email protected]>
…unded dispatch, and document it Always installing the transport-failure callback means a dispatch without an attempt bound now sees the attempt that dropped after connecting, so a later refusal is reported as possibly_delivered, not not_sent. Add the regression test and a compatibility note. Signed-off-by: Onur Yilmaz <[email protected]>
|
/ok to test 07f1b23 |
|
/ok to test 2a0a2e1 |
…n now always passes Collection installs the transport-failure callback on every /run dispatch, so a fake dispatch that names its keyword arguments must accept it. Signed-off-by: Onur Yilmaz <[email protected]>
|
/ok to test 4b39fe9 |
Signed-off-by: Onur Yilmaz <[email protected]>
|
/ok to test f4cb167 |
yuhezhang-ai
left a comment
There was a problem hiding this comment.
The previous review fixes still hold. I found one gap in the step-limit path brought in by the latest main merge: a scored episode that exhausts its environment-owned step budget is missing the warning. Please cover that path before approval is renewed.
…per episode With max_episode_steps the agent leaves the episode's limit to its caller and records nothing at it, so an episode that used its whole step budget, still calling tools, was scored without the agent_limit warning. The environment server now records it once when the step loop runs out of steps. Intermediate steps, an answer before the budget and an early task end stay unmarked, and the reply and reward are unchanged. Signed-off-by: Onur Yilmaz <[email protected]>
|
@yuhezhang-ai the step-limit gap from your last review is fixed in 3bd7893: with |
|
/ok to test 8f5c67f |
yuhezhang-ai
left a comment
There was a problem hiding this comment.
Verified the environment-owned step-limit fix: exhausted episodes now record one agent_limit event, while early completion stays unmarked and rewards and responses are unchanged. The original reproduction and focused regression checks pass. No remaining findings from my review. Approving; CI is still running on this revision.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/46497196080 |
…eplies-without-verdict Bring in #6675's merge of main dd09637. Resolve jailbreak_detection with main's #6393: the judge-failure paths that #6393 marked as scored despite a failure no longer exist here, because a failed judge call now masks the row. The one judge failure this branch still scores, a known zero kept when another judge fails, is recorded as scored despite a failure. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
What goes wrong
Part of #2750 (rollout failures bounded, visible and recoverable).
Several servers swallow a failure and go on to return a normal result. The rollout is then scored from a degraded path, and nothing says so: it cannot be told from one that was graded normally, so it quietly lowers a score or enters training. An audit of the failure path found these cases:
reward=0.0and only a log line (finance_agent,harbor_agent,mini_swe_agent,mini_swe_agent_2);status="failed"without a classified outcome, and the Environment Server verifies it as a normal reply (claude_code_agentand about 25 more agents never classify their failures);simple_agent,simple_agent_with_compaction,cvdp_agent);over_refusal_detection,jailbreak_detection);bigcodebench,math_formal_lean,swerl_gen);toolsandbox_agent);/runthat dropped after the request may have been delivered is resent and answered, and the row does not say the episode may have run twice;gym eval status, the same as one never attempted;What this changes
Nothing about how these rollouts are scored. The reward, the response, the retry decision and the exit code are as they were. This adds a record, and a place a user sees it.
observe_scored_despite_failure(nemo_gym.core) records an event with the operationscored_despite_failurein the request's failure log, the same logobserve_failureuses. The event travels with the reply and is saved beside the row (_ng_failure_events). It sets nofailure_id, because it is not the rollout's own failure.rollout_scored_despite_failurehealth check counts those events, so the run's health summary says how many rollouts were scored this way and from which failure kinds. Other saved events, such as the attempts of a model call that a retry recovered, are not counted.--health-check-ignore rollout_scored_despite_failureleaves it out.failedagent reply that has no classified outcome, and verifies it as before. This covers every agent that does not classify its failures, without editing each one.agent_run_error,agent_limit,judge_failed,verifier_error, andtransport_peer_dropfor a resent/run.gym eval statusshows the state and error of each post-run export, read from the result file the export step already writes. The receipt line is unchanged.The helper and the check are documented in the failure-model page and the health-check catalog.
Not changed
gym eval status, health findings and a plaingym eval runwith failures behave as before (require_completeis still off by default).nvarcand the malformed-patch path ofswerl_gen: a non-zero exit there can be the model's own crash, so a harness fault cannot be told from a wrong answer.environments/run in a sandbox with no request context. The misalignment monitor's fail-open and Harbor's tolerated session-close timeout are left out.Compatibility
Rewards, responses and exit codes are unchanged. Two changes affect an outcome on the failure path only, and both make a failure visible: the GitLab download now fails on an HTTP error (it saved the error page before), and a W&B run shows as failed after a failed delivery or evaluation.
A rollout that carries an event is now
unhealthyin the health report. The report already says a rollout can be correct by reward and still be unhealthy, androllout_tool_call_failedworks the same way. A user who sets--max-unhealthy-fractionwill see these rollouts count toward it, which is the point of that gate.Validation
/run, and the health check.test_tool_telemetry.pyfail, and they fail the same way on a cleanmain.finance_agent129,harbor_agent79,mini_swe_agent10,mini_swe_agent_229,toolsandbox_agent17,simple_agent172,simple_agent_with_compaction52,cvdp_agent37,single_agent_turn295,over_refusal_detection13,jailbreak_detection35, and viagym env test:bigcodebench19,math_formal_lean48,swerl_gen8.pre-commit run --files <changed files>: clean (the guardwords check was skipped because the private catalog is unavailable). DCO sign-off included.Rollout evidence
Real servers (
gym env start, thengym eval run --no-serve),over_refusal_detectionwithsimple_agent, a stub policy that answers and a stub judge that rejects every request:failure_id; ajudge_failedevent with operationscored_despite_failure, boundaryresources_server, stageverificationand the judge's errorrollout quality: 0 healthy / 1 unhealthy; therollout_scored_despite_failurefinding listsjudge_failedBefore this change the same rollout showed as healthy with nothing about the judge. The model was a stub, not a real model, and I ran only this server end to end; the other sites are covered by their tests.