Repository navigation
Conversation
A crashed harness run (sandbox OOM, runner error, context overflow) fails /run, which drops the rollout and with it the whole group from a training step. With score_failed_runs the failed run is verified as an empty response instead, so it trains as a zero and one pathological prompt cannot end a run. Off by default. Signed-off-by: Christian Munley <[email protected]>
|
/ok to test 0e5e487 |
|
/review |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
HOLD — 2 BLOCKER findings in the opt-in failure path.
The recovery boundary includes in-box verifier failures, and resource-owned sandboxes are destroyed before their verifiers can inspect them. Both can turn inconclusive verification into misleading zero-reward samples.
Reviewed both changed files and traced sandbox ownership, stateful verification, and token-capture finalization. Static review only; tests and live-model smoke rollouts were not 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.
…failed_runs Review follow-up. Two fixes to the opt-in failure path. An in-box sandbox_eval failure (grader exits nonzero, empty reward file) is raised as SandboxEvaluationFailed when score_failed_runs is on and is never turned into an empty response. A crashed grader says nothing about the policy, so it fails /run as before. With the option off the original exception propagates unchanged. A resource-owned sandbox from a failed run is no longer closed before /verify. Stateful verifiers (Terminal-Bench tests, R2E patch extraction) read it, so it is closed after verification returns. Verify errors and cancellation still close it through the existing handler. Tests: the recovery test asserts the sandbox is still up when /verify runs and closed after. A run() test with the real responses() path covers a failed grading command and an empty reward file with the option on and off: no /verify call, sandbox cleaned up. Signed-off-by: Christian Munley <[email protected]>
Resolves the conflict with #5033 (require_tool_call) in harness_agent run(): both config fields are kept, the tool-call gate runs on the verify result and a scored failure closes its sandbox after it. Signed-off-by: Christian Munley <[email protected]>
|
/ok to test 42fc800 |
|
/review |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP — both prior BLOCKER findings are resolved; no eligible findings remain in this follow-up.
- In-box grading failures now bypass failed-run recovery, preserving exception propagation and preventing
/verifycalls (implementation, regression tests). - Recovered failures retain resource-owned sandbox state through verification and clean up afterward; exceptional-path cleanup remains intact (implementation, ordering regression).
Compared both changed files with the previously reviewed head and traced directly affected grading, stateful verification, cleanup, and merged tool-call gating. Static review only; tests and live-model smoke rollouts were not 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 findings-only review. Request a full review with /review reset=true.
Resolve conflicts with main. Signed-off-by: Christian Munley <[email protected]>
|
/ok to test 06dbeb6 |
|
/review |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP — no eligible findings remain in this follow-up.
Both previously verified fixes remain intact:
- In-box grading failures bypass failed-run recovery rather than becoming policy scores (implementation, regression coverage).
- Recovered runner failures keep resource-owned sandboxes available through verification and clean up afterward; exception and cancellation cleanup remain intact (implementation, ordering regression).
Compared both changed files with the previously reviewed head, 42fc800a3b241c0f46d1cd2e99634ee93cb335d7, and traced the directly affected infrastructure masking, grading, sandbox lifecycle, tool-call gating, and model URL paths. This was a follow-up under the historical moderate impact ceiling, not a fresh full-PR review. Static review only; tests and live-model smoke rollouts were not executed.
Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.
yaoyu-33
left a comment
There was a problem hiding this comment.
HOLD at 06dbeb6bacb7. Thanks for this. Keeping one crashing prompt from ending a training run is useful, and the two earlier bot blockers (in-box grading failures, closing the sandbox before /verify) are fixed.
The question for this review was whether an infrastructure failure can now be scored as reward 0 instead of masked. With the option on, it can in two ways. A container lost mid-run on the Docker, Apptainer, Enroot and OpenShell providers is scored, and can train a partial chain at reward 0. A runner exec timeout is scored too, and on Docker the runner can still be running during /verify. Provisioning and config failures are scored too, though token capture masks those later. The option is opt-in and off by default, and with it off nothing changes. Details and suggested fixes are in the inline comments.
Checked: the harness_agent tests at this head pass on a Linux workstation (63 passed; 2 failures came from my partial checkout and don't involve this PR). A probe confirmed the scored provisioning and config paths. The branch merges cleanly with #5085, which changes the same failed-run path, and the two don't interact: a scored run releases its session through /verify. Not run: a real rollout.
| raise | ||
| except Exception as exc: | ||
| # A sandbox infra failure is masked below, never scored. | ||
| if not self.config.score_failed_runs or sandbox_infra_failure_kind(exc) is not None: |
There was a problem hiding this comment.
BLOCKER: a container lost mid-run is scored, and can be trained at reward 0. (runner check)
On Docker, Apptainer, Enroot and OpenShell, a lost container comes back as an exec result, not an exception: return_code=125, error_type="sandbox" (for example docker/provider.py#L740-L743). The runner check reads only return_code, so it raises a plain RuntimeError("runner failed (125)"), and sandbox_infra_failure_kind doesn't recognise that. With score_failed_runs=True the run is scored instead of masked. By then the harness has usually made model calls, so with token capture on, the captured partial chain can be delivered and trained at reward 0. That penalises the policy for an infrastructure loss. Before this PR it was a /run 500, so nothing trained on it. (OpenSandbox isn't affected: it raises a sandbox-boundary NgFailureEvent.)
The same goes for error_type="timeout". On timeout the Docker provider kills only the local docker exec client (docker/provider.py#L359-L364). In a resource-owned sandbox the runner can keep running, so a stateful /verify reads a workspace the agent is still writing.
Could the runner exec raise a typed sandbox failure whenever r.error_type is set, so the existing masking path handles it? If you want rollout_timeout expiry scored as a policy failure, the runner would first have to be confirmed stopped, and the run masked if that can't be confirmed. A test where the runner exec returns SandboxExecResult(None, "container is not running", 125, error_type="sandbox") with the option on, asserting a masked result and no /verify, would cover it.
| try: | ||
| agent_resp = await self.responses(request, body.responses_create_params) | ||
| agent_resp_json = agent_resp.model_dump(mode="json") | ||
| except SandboxEvaluationFailed: | ||
| raise | ||
| except Exception as exc: | ||
| # A sandbox infra failure is masked below, never scored. | ||
| if not self.config.score_failed_runs or sandbox_infra_failure_kind(exc) is not None: | ||
| raise | ||
| LOG.warning("harness run failed, scoring it as an empty response", exc_info=True) | ||
| # a stateful verifier may still read the resource-owned sandbox, close it after /verify | ||
| scored_failure = True | ||
| agent_resp_json = _empty_response(body.responses_create_params).model_dump(mode="json") |
There was a problem hiding this comment.
RISK: the scoring boundary covers all of responses(), not just the harness run.
Besides runner failures, this also scores everything _provision_box raises (L445-L497): a failed setup_commands step, the gym source fetch or extract, and the model-endpoint reachability probe. It also scores config errors: forward_mcp_tools with a non-Claude-Code agent (L563-L566), or a provider that cannot connect. I ran a probe on a Linux workstation: with the option on, a failing setup command, an unreachable model endpoint and that forward_mcp_tools misconfig each went /seed_session → /verify and came back mask_sample=False. Token capture masks these later because no model call was captured, but rollout health and the reward metrics count them as scored policy failures. A misconfigured job then reports reward 0 on every row instead of failing fast.
Could you raise a dedicated exception (for example HarnessRunFailed) only from the runner-exit check and the response.json download/validation, and catch only that here? That still covers what the option is for (runner crash, context overflow, OOM inside a box that survives), and everything else keeps today's behavior. It would also make SandboxEvaluationFailed and the wrapping at L604-L613 unnecessary.
| ): | ||
| verify_json["reward"] = 0.0 | ||
| return HarnessAgentVerifyResponse.model_validate(verify_json) | ||
| result = HarnessAgentVerifyResponse.model_validate(verify_json) |
There was a problem hiding this comment.
RISK: a scored failure looks the same as a genuine reward 0. Nothing on the row records that the harness crashed; the only trace is the log warning. Also, the empty response carries the id harness-agent-sandbox-failure (L124), which is the id masked sandbox results use, so a scored row is labelled as a sandbox failure. BaseVerifyResponse covers this case: a sample that was still measured keeps mask_sample=False but names failure_kind/failure_reason. Could the scored path set failure_kind=failure_kinds.AGENT_RUN_ERROR and a truncated failure_reason from the exception, and give the empty response its own id? Then the scored-failure rate shows in rollout health and can be filtered.
| # Score a crashed harness run (sandbox OOM, runner error, context overflow) as an empty | ||
| # response instead of failing /run, so one pathological prompt cannot end a training run. | ||
| score_failed_runs: bool = False |
There was a problem hiding this comment.
DOC: please document what this option scores.
(1) "sandbox OOM" here doesn't match the code. An OOM that the provider reports is masked by sandbox_infra_failure_kind. Only a process killed inside a box that survives shows up as a runner failure and gets scored.
(2) The option isn't in responses_api_agents/harness_agent/README.md. Could you add a short section covering:
- what gets scored: the runner exits nonzero or prints no
RUNNER_DONE, includingrollout_timeoutexpiry and a harness that gives up because the model server went down mid-run (this layer can't tell that apart); - what stays masked or fails
/run: sandbox infrastructure failures and in-box grading failures; - the token-capture behavior from the PR description: no captured calls means masked, and a partial chain trains at the verifier's score.
That last point is the trade-off anyone turning this on for training needs to know.
| agent._provider.close.assert_awaited_once_with(handle) | ||
|
|
||
|
|
||
| async def test_failed_run_is_verified_as_empty_response_when_scored(): |
There was a problem hiding this comment.
TEST: the guard that keeps infrastructure failures masked is untested in scored mode. The masking tests (L826-L903) all run with the option off. So deleting or sandbox_infra_failure_kind(exc) is not None at app.py L369 or L611 keeps the suite green. Could you parametrize test_sandbox_ending_mid_episode_masks_the_rollout_instead_of_failing_run and test_backend_loss_masks_the_rollout over score_failed_runs, asserting the masked result and no /verify call? Also, assert result.reward == 0.0 in this test only echoes the mocked /verify reply. If the mock returns a nonzero reward, the test shows the verifier's score passes through.
| # A sandbox infra failure is masked below, never scored. | ||
| if not self.config.score_failed_runs or sandbox_infra_failure_kind(exc) is not None: | ||
| raise | ||
| LOG.warning("harness run failed, scoring it as an empty response", exc_info=True) |
There was a problem hiding this comment.
PROCESS: real smoke evidence. Could you add one real rollout with score_failed_runs: true where the harness actually fails? For example, a small max_output_tokens or context window that makes the runner exit nonzero. Paste the rollout row (reward, mask_sample, and the token-capture build's mask_sample if capture was on). AGENTS.md asks for a real smoke on behavior-changing agent work, and the unit tests here mock responses(). The description could also link the issue that tracks this (or say why none is needed). It also still says the sandbox is closed before /verify; at this head it's closed after.
|
/ok to test 06dbeb6 |
What broke
When a harness run inside
harness_agentcrashes (sandbox OOM, runner error, context overflow),/runraises. Rollout collection loses that rollout, and a group-based trainer then loses the whole prompt group with it, so one pathological prompt can stall or end a training run.Fix
A new
score_failed_runsoption onHarnessAgentConfig, off by default. When it is on and the harness run raises, the agent logs the failure, closes the run's sandbox, and sends an empty response (no output items) to the resources server's/verify. The rollout is then scored, normally as reward 0, instead of failing/run.With the option off, nothing changes: the exception propagates and the sandbox is closed as before.
Token capture
With token capture on, the training sample is rebuilt from the captured model calls, not from this empty response. A run that crashed before its first model call has no captured tokens, and the token-capture consumer masks it (an empty delivery is never trainable). A run that crashed after some model calls keeps its captured chain: it trains at the verifier's score when it builds as one unambiguous chain, and is masked otherwise.
Test
responses_api_agents/harness_agent/tests/test_app.py::test_failed_run_is_verified_as_empty_response_when_scoredmakes the harness run raise withscore_failed_runs=Trueand checks that/verifyreceives an empty response, the resource-owned sandbox is closed, and the reward is 0.test_config_defaultschecks the option is off by default. All 32 harness_agent tests pass.