Skip to content

fix(terminal_bench_2_1): mask verifier and sandbox infra errors instead of scoring 0 - #5675

Merged
AdamRajfer merged 9 commits into
mainfrom
arajfer/tb21-verifier-infra-errors
Nov 9, 2026
Merged

AdamRajfer merged 9 commits into
mainfrom
arajfer/tb21-verifier-infra-errors

Conversation

@AdamRajfer

@AdamRajfer AdamRajfer commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Behaviour. Terminal-Bench 2.1 scored a reward of 0 for any exception in the verifier (uploading the tests, running test.sh, downloading reward.txt), so a lost sandbox counted as a wrong answer. terminus-2 turned provider failures into a custom sandbox-loss exception that implied an HTTP 503 and a retry.

  • Verifier infrastructure failures (the sandbox cannot run test.sh, a connection error during upload or download) are reported through observe_failure, keep the caught exception, including a provider NgFailureEvent, as the cause, and leave the row unscored (evaluation_completed: false). A typed provider failure keeps its provider kind; a verifier-side failure is verifier_error.
  • The verifier outcome policy (outcome_policy) chooses between masking the sample (retry, the default) and an unmasked zero (count_as_zero). The applied action and attribution are returned as failure_outcome_action and failure_outcome_attribution, so a saved row and recovery read the decision instead of inferring it.
  • A failed reward.txt download, typed or not, is a failed grade only when the sandbox answers test -f with exit 1. Any other probe result is inconclusive and the sample is masked.
  • These still score 0, as before: a test.sh result with error_type="timeout", a nonzero mkdir of the upload or /logs/verifier directory on a healthy sandbox, and an absent or invalid reward.txt.
  • terminus-2: the sandbox adapter forwards a provider NgFailureEvent unchanged and reports a raised transport error or a structured sandbox error as provider_unavailable with the original as cause. An ordinary nonzero command exit stays a command result. In an agent session the harness returns a failed response carrying the provider event and its kind; the Environment Server's agent_outcome_policy selects retry or fail by kind, not by the HTTP status of the cause. Cancellation and the legacy /run path still raise.
  • The default agent outcome policy retries provider_unavailable, provider_io_timeout, provider_status_unavailable, provider_command_outcome_unknown, provider_protocol_error, provider_request_failed, provider_internal_error and provider_pty_unavailable, as the earlier status-based handling did (provider_command_timeout is not retried by default, since an agent command deadline can be the model's own). This is an episode-level retry; it does not replay an uncertain command inside the provider, and a configured kind rule overrides it.

Validation. Covered by unit tests only; no live rollout was run.

  • resources_servers/terminal_bench_2_1/tests: 127 passed, 13 skipped (fixture-dependent). The tests cover masking and unmasked-zero outcomes for each failing verifier operation, the reward-download probe, the provider event and cause surviving the failure header, a configured outcome policy changing the outcome, and a saved row from the real verify method counted by the recovery gate.
  • environment_servers/single_agent_turn/tests: 216 passed. run_request is exercised for each retryable provider kind, with and without a configured kind rule and with different cause statuses, keeping the provider event as the cause.
  • responses_api_agents/terminus_2_sandboxed_agent/tests: 168 passed with Harbor 0.22.0 installed separately; they do not collect without Harbor.
  • Nearby suites also pass: tests/unit_tests/agents, tests/unit_tests/rollouts, the outcome-policy, shared-fault-class, masked-recovery and recovered-policy-gate orchestration tests (3289 passed, 2 skipped), and single_agent_turn_legacy (43 passed).
  • No before/after reward profile, real model rollout, or live sandbox provider run exists for this change, so the effect on reported scores on real tasks is not measured.

Revert. Revert this PR.

…ad of scoring 0

The verifier scored reward 0 for any exception while uploading tests, running test.sh or downloading reward.txt, and
the terminus-2 terminal raised a plain RuntimeError for tmux control failures, which fell into the scored "failed"
branch. Verifier infrastructure errors are now reported as VERIFIER_ERROR with observe_failure, and terminal control
failures raise SandboxLostError, so the agent reports an infrastructure error.

A test.sh timeout, a broken /logs/verifier directory and an absent or invalid reward.txt still score 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/ok to test 3f59539

@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.

HOLD

The new classifier can exclude model-caused failures from evaluation and still count some sandbox failures as wrong answers. The inline findings describe the affected branches and preservation checks.

RISK — Supply the required real-rollout and before/after reward evidence. This changes a fixed benchmark’s scoring population and the agent’s failure handling, but the PR description reports only fake-sandbox tests and explicitly excludes a live-provider end-to-end run. The review rubric requires before/after reward-profiling evidence for benchmark-verifier changes, and AGENTS.md requires representative real model rollouts for behavior-changing agent work. Without those results, the provider-facing classification and its effect on reported scores remain unvalidated.

Add the evidence to the PR’s validation section after correcting the classifier: identify the tasks, model, provider and configurations, and report base/head mean reward, measured/masked counts, and failure-kind counts with artifact references. Inspect representative agent and verifier trajectories. Healthy passing and failing tasks should retain their grades; task-caused terminal/filesystem failures should remain verifiable or scored failures; genuine provider failures should be unscored. Explain the intended aggregate shift from removing infrastructure zeros, rather than treating any score increase as confirmation. This is a validation handoff, not an executed experiment.

I inspected all five changed files and traced the directly affected sandbox, agent-outcome, failure-reporting and metric contracts. I couldn't execute tests or live rollouts in this read-only review.

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.

…biguous timeouts and probe exits as inconclusive

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

On the real-rollout evidence: this PR has no live-provider run, as the description says. The classification is covered with fake sandboxes, including the cases above (task-caused upload and terminal failures stay scored, provider failures are masked).

AdamRajfer added a commit that referenced this pull request Nov 5, 2026
Signed-off-by: Adam Rajfer <[email protected]>

@giuliolovisotto giuliolovisotto 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.

Please complete the touched failure paths using the shared NgFailureEvent contract, rather than retaining custom sandbox-loss exceptions and using HTTP status as the outcome decision. The immediate issues are ordinary command exits being promoted to sandbox loss, provider events losing their identity/cause across the agent route, and caught verifier failures being recorded without their original cause. Preserve observed facts, let the owning boundary apply the configurable outcome policy, and persist the applied decision when returning a handled result.

Validation: the TB2.1 suite passed 54 tests with 13 fixture-dependent skips. A direct verify-method probe reproduced loss of the original provider event, including its ID and HTTP 503. An extracted terminal-method probe reproduced SandboxLostError from a normal exit 127. The Harbor-dependent terminal suite could not collect in the review environment. No live rollout or merged-main integration was run. Some of the custom agent handling predates this patch; migrating that connected path is part of the requested contract alignment.

…om exceptions

The Terminus 2 sandbox adapter forwards a provider NgFailureEvent unchanged and
reports a raised transport error or a structured sandbox error as a
provider_unavailable event with its cause, so the id, kind, status and details
survive the agent route. The route fails with an agent route failure whose cause is
that event, and the boundary that owns the outcome applies its policy; no custom
exception implies an HTTP status or a retry. A nonzero command exit stays an
ordinary result and the terminal helpers raise plain RuntimeError again.

The Terminal-Bench 2.1 verifier links its verifier_error event to the caught
exception, so a provider event arriving at verify keeps its identity in the failure
report. A typed provider failure while downloading the reward masks the sample
without a probe, and the recorded reason no longer embeds raw exception text.

Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

I reworked this on the shared NgFailureEvent contract in 96f5126. The Terminus 2 adapter forwards provider events with their identity, a nonzero command exit stays an ordinary result, and the verifier event now carries the caught exception as its cause. The Terminus 2 and TB2.1 suites pass, including the harbor-dependent terminal tests that did not collect before.

@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team November 6, 2026 10:50
When the failure that stops verification is a typed provider event, the verify
response and the verifier-stage event carry that event kind and status, with the
event itself as cause. Only verifier-side failures remain verifier_error.

Signed-off-by: Adam Rajfer <[email protected]>

@giuliolovisotto giuliolovisotto 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.

@AdamRajfer Rechecked c659e43. I resolved the ordinary-terminal-exit and verifier-cause threads: those fixes hold. Approval remains blocked by the typed-download shortcut and the outstanding policy application point described below.

CI also has a deterministic public-import failure: resources_servers/terminal_bench_2_1/tests/test_app.py imports FailureHeader from nemo_gym.core.failure_transport; it is exported from nemo_gym.core and should be imported there. Failed job: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42205997960/job/127853696288

Local TB2.1 validation: 118 passed, 13 fixture-dependent skips. The missing-reward probes used the actual verify method; the current-contract probe loads this PR's module against the newer shared failure schema. This is not a complete merged-main or live-provider run. Harbor-dependent tests were not available locally.

…licy

An agent session reports a sandbox or model infrastructure failure as a failed
response carrying the provider event, and the Environment Server selects retry
or fail from its agent_outcome_policy by failure kind instead of from the HTTP
status. The Terminal Bench 2.1 verifier applies an outcome_policy of its own
(retry masks the sample, count_as_zero scores it) to a verification that could
not produce a verdict.

A failed reward download is a failed grade only when the sandbox confirms that
reward.txt is absent, typed or not, so a provider 404 for a missing file is no
longer masked. Import FailureHeader from nemo_gym.core.

Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

Pushed 3d999fa for the second round. CI: FailureHeader is now imported from nemo_gym.core, and the public-API facade tests pass. Reward-absence confirmation is applied to typed download failures too, and the stage policy is wired for the agent session path and the TB2.1 verifier. The agent-stage rule lives in the Environment Server's agent_outcome_policy.by_failure_kind; the verifier rule is outcome_policy.by_failure_kind on the TB2.1 resources server.

@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team November 6, 2026 11:51
@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Nov 6, 2026
@kajalj22
kajalj22 removed the request for review from a team November 6, 2026 22:50
@svcnvidia-nemo-ci svcnvidia-nemo-ci added bug Something isn't working area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers needs-review PR is ready for code review and waiting on a reviewer labels Nov 7, 2026
…verifier's applied decision

An agent that reports a sandbox provider failure now forwards the specific
provider kind, so the default agent outcome policy has to retry the transient
ones the way the previous status-based handling did. Add provider_io_timeout,
provider_status_unavailable, provider_command_outcome_unknown and
provider_protocol_error next to provider_unavailable. This is an episode-level
retry decision; it does not replay an uncertain command inside the provider,
and a configured kind rule still overrides it.

The Terminal-Bench 2.1 verifier now returns the policy action and attribution
it applied (failure_outcome_action and failure_outcome_attribution), so a
configured count_as_zero survives a saved row and recovery counts it as a
legitimate zero instead of treating it as masked.

Tests run the Environment Server's run_request for each retryable kind, with and
without a configured rule and with different cause statuses, and keep the
provider event as the cause. The verifier test saves the row from the real
verify method and runs it through the recovery gate.

Signed-off-by: Adam Rajfer <[email protected]>
…by default

provider_request_failed, provider_internal_error and provider_pty_unavailable
are environment faults that the earlier status-based handling retried, so the
default agent outcome policy retries them too. provider_command_timeout stays
unlisted because an agent command deadline can be the model's own. The policy
remains configurable.

The run_request and Terminus session tests cover the three kinds.

Signed-off-by: Adam Rajfer <[email protected]>

@giuliolovisotto giuliolovisotto 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.

Re-reviewed e7be213 and the latest follow-up commits. The outstanding transient-provider retry and saved verifier-decision issues are addressed, including the saved-row recovery regression. Focused validation: 203 passed, 13 skipped. No live provider/model rollout was run during this re-review.

CI still has pending checks; this approval does not claim those have finished.

@AdamRajfer
AdamRajfer added this pull request to the merge queue Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42630328561

Merged via the queue into main with commit 312de5e Nov 9, 2026
68 checks passed
@AdamRajfer
AdamRajfer deleted the arajfer/tb21-verifier-infra-errors branch November 9, 2026 14:15

This branch was previously deployed

1 inactive deployment
public — e7be2134 Deployed Nov 9, 2026 by copy-pr-bot[bot] via release / finalize / notify #11012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants