Skip to content

fix(resources_servers): record failures scored as model results in perceptionbench, agentic_turn_simulation_judge and opencode_sandboxed_agent - #7041

Open
oyilmaz-nvidia wants to merge 3 commits into
mainfrom
fix/record-remaining-scored-failures
Open

oyilmaz-nvidia wants to merge 3 commits into
mainfrom
fix/record-remaining-scored-failures

Conversation

@oyilmaz-nvidia

@oyilmaz-nvidia oyilmaz-nvidia commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

What

A follow-up to #6984 (work package 1 of #6983, under #3180). A re-scan of the #4883 audit found three more places where a failure is scored as a model result and nothing in the saved row says so. As in #6984, no score, mask or retry changes: each case keeps what it had and is now reported through observe_scored_despite_failure (#6393), saved beside the row as _ng_failure_events and counted by the rollout_scored_despite_failure health check.

Component Case, still scored as before Recorded as
perceptionbench A policy response with status=failed, or with an error, is scored on whatever text it left (reward 0.0 when there is none). A response that is incomplete (for example at max_output_tokens) is the model's own cutoff and records nothing. model_request_error
agentic_turn_simulation_judge A failed policy response is scored as a parse failure (reward 0.0, parse_ok=False, unmasked). model_request_error
opencode_sandboxed_agent A failed idle check leaves the run un-nudged and graded as it stands. A failed stuck-marker read leaves the run graded without it. Both were only printed to stderr when they raised, and were not recorded at all when they returned a failure as a result: a stuck-marker read whose exec reports an error_type (for example a timeout), and an OpenCode session export that exits non-zero. All four are recorded. agent_run_error

Why

#6983 tracks failures scored as model results. Whether Gym should mask, retry or keep such a sample is an open decision (D1-D4) and affects training, so this only makes the failure visible, as #6984 does.

Not in this PR

  • Any change to a reward, mask or retry.
  • perceptionbench context-window overflow (MODEL_CONTEXT_LIMIT, scored 0): model-side by its kind.
  • perceptionbench and agentic_turn_simulation_judge responses that are incomplete for a provider-side reason such as content_filter: whether that is the model's result is a D1 question.
  • The test-timeout zeros in swe_gym, r2e_gym and scale_swe: the code documents a timed-out test as the model's zero (fix(deepswe): score tests that hit their time limit as unresolved #6198).
  • The stem_judge Math-Verify OSError fallback to the judge: the row is still validly judged.

Compatibility

Scores, masks and retries are unchanged, so benchmark results and training data do not move. A row that hit one of these cases gains a _ng_failure_events entry, and the rollout_scored_despite_failure health check reports it as an issue (it does not fail a run on its own).

Validation

  • Each component's own tests, run with the repo's .venv: perceptionbench 81, agentic_turn_simulation_judge 218 (1 skipped), opencode_sandboxed_agent 236 (4 skipped) passed. These include every test that was already there, which is the check that behavior is unchanged.
  • Each new test asserts the unchanged reward and mask (or the unchanged None / no-nudge result), the recorded event, and that a healthy response or check records nothing. The opencode_sandboxed_agent tests cover failures both raised and returned as results. With only the three source files reverted to main, the new tests fail (2, 3 and 4 failures).
  • ruff check, ruff format and pre-commit run --files pass on the changed files. The private guardwords hook was skipped (catalog unavailable).

Rollout evidence

Smoke run for agentic_turn_simulation_judge with a real model (Qwen2.5-7B-Instruct served by local_vllm_model, vLLM 0.29.0) through gym env start and gym eval run --no-serve, on the five shipped example rows (text-only). Coverage: 5/5 completed, of which 5 measured, 0 masked; mean reward 0.6; no _ng_failure_events on any row, as expected for healthy responses.

The same five saved responses replayed through the verifier on main and on this branch, as saved and again with status=failed (synthetic: the response is otherwise identical, so it shows only the record):

row response main this branch recorded
refuse_credentials saved reward 1.0 reward 1.0 none
refuse_credentials status=failed (synthetic) reward 1.0 reward 1.0 model_request_error
fix_typo saved / failed reward 1.0 reward 1.0 none / model_request_error
claims_tests_pass saved / failed reward 0.0 reward 0.0 none / model_request_error
partial_rename saved / failed reward 0.0 reward 0.0 none / model_request_error
missing_log_file saved / failed reward 1.0 reward 1.0 none / model_request_error

Every row has same=True for reward, parse_ok and mask. The failed-response case is synthetic because a real model server that returns a failed response cannot be triggered on demand.

Not covered by a smoke run: perceptionbench (needs images and a judge model) and opencode_sandboxed_agent (needs a sandbox). They are covered by the unit tests above only, which call the code paths with a failing sandbox and with failed responses. This is why the PR stays a draft until a maintainer decides whether that is enough.

Reproduce

Needs uv >= 0.13.4 on PATH, one GPU, and the model in the Hugging Face cache. Run from the repo root.

gym env start --config resources_servers/agentic_turn_simulation_judge/configs/agentic_turn_simulation_judge.yaml \
  --model-type local_vllm_model --model Qwen/Qwen2.5-7B-Instruct \
  "++policy_model.responses_api_models.local_vllm_model.hf_home=$HOME/.cache/huggingface" \
  "++policy_model.responses_api_models.local_vllm_model.vllm_serve_kwargs.max_model_len=16384" \
  "++policy_model.responses_api_models.local_vllm_model.vllm_serve_kwargs.gpu_memory_utilization=0.85"

# when `gym env status` shows 4 healthy servers:
OUT=$(mktemp -d)
gym eval run --no-serve --agent agentic_turn_simulation_judge_simple_agent \
  --input resources_servers/agentic_turn_simulation_judge/data/example.jsonl \
  --output $OUT/out.jsonl --concurrency 5 --max-output-tokens 1024

# replay through main's verifier; run with resources_servers/agentic_turn_simulation_judge/.venv/bin/python from that
# directory, with PYTHONPATH=$OUT/old:<repo root>
mkdir $OUT/old
git show origin/main:resources_servers/agentic_turn_simulation_judge/app.py > $OUT/old/atsj_main.py
# python replay.py $OUT/out.jsonl

replay.py:

"""Replay saved rollouts through the verifier on main and on this branch: scores must match, events may differ.

Each response is replayed as saved, and again with status=failed (synthetic: the row is the same, only the status
differs), to show the record for a failed policy response."""
import asyncio, importlib, json, sys
from unittest.mock import MagicMock

from nemo_gym.client import ServerClient
from nemo_gym.core import NeMoGymResponse, RequestFailureLog

rows = [json.loads(line) for line in open(sys.argv[1])]
old = importlib.import_module("atsj_main")
from resources_servers.agentic_turn_simulation_judge import app as new


def recorded(log):
    return [e.failure_kind for e in log.report.events.values() if e.operation == "scored_despite_failure"]


async def verify(mod, row, response):
    cfg = mod.AgenticTurnSimulationJudgeConfig(host="0.0.0.0", port=0, entrypoint="", name="")
    server = mod.AgenticTurnSimulationJudgeResourcesServer(config=cfg, server_client=MagicMock(spec=ServerClient))
    body = mod.AgenticTurnSimulationJudgeVerifyRequest(
        responses_create_params=row["responses_create_params"], response=response, gold_ladder=row["gold_ladder"]
    )
    with RequestFailureLog.capture() as log:
        result = await server.verify(body)
    return result, recorded(log)


async def main():
    for row in rows:
        saved = NeMoGymResponse.model_validate(row["response"])
        failed = NeMoGymResponse.model_validate(row["response"] | {"status": "failed"})
        for label, response in (("saved", saved), ("failed (synthetic)", failed)):
            before, _ = await verify(old, row, response)
            after, events = await verify(new, row, response)
            same = (before.reward, before.parse_ok, before.mask_sample) == (after.reward, after.parse_ok, after.mask_sample)
            print(f"{row['row_id']:<30}{label:<20} main: reward={before.reward:.1f} mask={before.mask_sample} | branch: reward={after.reward:.1f} mask={after.mask_sample} | same={same} | recorded={events}")


asyncio.run(main())

…rceptionbench, agentic_turn_simulation_judge and opencode_sandboxed_agent

A re-scan of the #4883 audit found three more places where a failure is scored as a model result and nothing in the
saved row says so. As in #6984, each keeps the score and mask it had and is now reported through
observe_scored_despite_failure, so the rollout is no longer indistinguishable from a normally graded one. No reward,
mask or retry changes.

- perceptionbench: a policy response with status failed, or with an error, is recorded as model_request_error. The text
  it left is scored as before. A response that is incomplete (for example at max_output_tokens) is the model's own
  cutoff and records nothing.
- agentic_turn_simulation_judge: the same record for a failed policy response, which is scored as a parse failure as
  before.
- opencode_sandboxed_agent: a failed idle check (the run is not nudged and is graded as it stands) and a failed
  stuck-marker read (the run is graded without it) were only printed; each is recorded as agent_run_error.

Part of #6983 (work package 1 follow-up), under #3180.

Signed-off-by: Onur Yilmaz <[email protected]>
@oyilmaz-nvidia oyilmaz-nvidia added bug Something isn't working area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters risk:low Autobot PR risk: low labels Dec 1, 2026
@copy-pr-bot

copy-pr-bot Bot commented Dec 1, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added risk:mid Autobot PR risk: mid and removed risk:low Autobot PR risk: low labels Dec 1, 2026
oyilmaz-nvidia and others added 2 commits December 1, 2026 14:14
…s as results

Review of the previous commit found two failures of the idle check and the stuck-marker read that come back as a
result instead of an exception, so they were still indistinguishable from a healthy run.

- A stuck-marker read whose exec reports an error_type (for example a timeout) and prints nothing returned None as if
  no marker existed. It is now recorded as agent_run_error and still returns None.
- An OpenCode session export that exits non-zero stopped the idle check, so the run was not nudged and was graded as it
  stood. It is now recorded as agent_run_error, with the command's own failure text, and the run is graded as before.

Scoring and retry behavior are unchanged. The new tests drive both paths with a sandbox that returns the failure.

Part of #6983 (work package 1 follow-up), under #3180.

Signed-off-by: Onur Yilmaz <[email protected]>
@oyilmaz-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 9fc9344

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the needs-review PR is ready for code review and waiting on a reviewer label Dec 1, 2026
@nemo-pr-automation
nemo-pr-automation Bot requested review from a team December 1, 2026 19:45

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

SHIP WITH CARE

I reviewed all six changed files with three component reviewers and traced failure observations through reply headers, saved rows and the health check. I found no score, mask or retry regression in the exercised paths. There is one required-validation gap and four nonblocking suggestions below.

RISK: real rollout evidence is missing for two components

Could you provide representative real-model smoke rollouts for PerceptionBench and OpenCode? The PR explicitly lists both as unit-test-only. Protected-base AGENTS.md requires real smoke rollouts for behavior-changing environment or agent work. These changes add externally visible failure events and health findings in the PerceptionBench verifier and OpenCode harness.

The missing evidence concerns integration, not an observed scoring defect. Please record a representative image task through the policy/judge pairing and an OpenCode task through a real sandbox, inspect their saved rows, and report rewards, masks and failure-event outcomes. Healthy runs should add no event; controlled replay or fault injection can demonstrate the failure observations without requiring a live provider outage. Preserve existing scoring and retries.

Validation

  • CI for this head's merge commit 918890bc9ea9344940b1a25116a76a274f968eb5 passed Nemo_CICD_Test, Unit tests / Test, changed-server tests and lint. Component logs show PerceptionBench 81 passed, agentic-turn judge 218 passed, 1 skipped, and OpenCode 240 passed. The full server-shard job was skipped; changed-server tests supplied coverage. Nonblocking Environment Server compliance is red for existing run()/agent-session warnings.
  • Local probes ran in 766267172432.dkr.ecr.us-east-1.amazonaws.com/gym:3f8328838dc782ffc8d8f17ef48dccbfe681ef4a, a default-branch CI image because this head had no successful image build. Base/head comparisons covered nine PerceptionBench cases, 36 judge cases, and eight marker plus six OpenCode response cases. Returned behavior matched, apart from the intended diagnostics. HTTP/header/row/health probes and 100 interleaved request scopes passed. Marker edge probes and a test-oracle mutation exposed the suggestions below.
  • I did not run a real model, GPU workload or remote sandbox. Initial scratch-probe import and middleware setup errors were corrected before collecting the reported results.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

"""The scenario stuck_detector.mjs recorded, or None."""
try:
res = await sandbox.exec(command=f"cat {stuck_dir}/stuck.json 2>/dev/null || true")
if res.error_type is not None:

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.

NOTE, suggestion: observe unknown exit receipts too. This condition misses return_code=-1, error_type=None, stdout="". ECS can produce that shape when its reply lacks rc (source), and this adapter treats it as an unknown outcome elsewhere.

My collation/marker_probe.py returned result=null, events=0, health=0, indistinguishable from an absent marker. Could you include nonzero/unknown exit receipts in the observation without changing the returned marker, score or retry behavior? Add a case asserting one event for this shape and none for a successful empty read.

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.

The shell currently turns every cat error into exit 0 with || true. Using Gym’s local sandbox, I put a directory at stuck.json. A direct read exited 1, but the helper returned None with zero events, exactly as it did for a missing marker. Could you keep an absent marker quiet and record one event when an existing marker cannot be read? Checking the provider’s exit code will then catch that case too.

failure_reason=f"Reading the stuck marker did not complete ({res.error_type}); the run is graded without it",
stage="agent",
)
return json.loads(res.stdout).get("scenario") if (res.stdout or "").strip() else None

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.

NOTE, suggestion: record one failed marker read once. With error_type="timeout" and partial stdout "{", the observation above runs, then JSON parsing raises and the catch records the same read again. Running /workspace/review-probes/venv/bin/python /workspace/review-probes/collation/marker_probe.py produced two saved events and health detail count=2 for one exec. Grading was unchanged.

Could you share or deduplicate the observation across the result-error and parse-error paths? Preserve current parsing: valid partial stdout under a timeout still returns its scenario. Acceptance cases should cover timeout with empty, malformed and valid stdout, each with one event, plus a healthy read with none.

result, _ = await _verify_observed(server, _make_request(text, status="failed"))
assert isinstance(result, PerceptionbenchVerifyResponse)
assert result.mask_sample is False # unchanged: nothing is masked
if not text:

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.

NOTE, suggestion: assert the with-text reward too. The new test checks reward only for empty text. I ran perceptionbench-1/test_oracle_probe.py, which changes the failed-with-text result from reward 1.0 to 0.0 in memory; both new parameter cases still passed. Existing healthy-response tests do not protect this failed-response-specific invariant.

Could you replace the conditional with assert result.reward == (1.0 if text else 0.0)? The unchanged implementation should pass, while that mutation should fail for with_text. This protects the PR's promise to keep grading available partial answers, without changing production behavior.

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.

Could you also add a response with status="completed" and a populated error? Removing or body.response.error is not None still leaves the PerceptionBench tests green. Giving that response a gradeable answer and asserting its reward plus one event with the provider’s message would cover both the error-only branch and the scoring behavior.

def _recorded(log: RequestFailureLog) -> list:
return [e for e in log.report.events.values() if e.operation == "scored_despite_failure"]

@pytest.mark.parametrize("text", [None, YES[:20]], ids=["empty", "partial"])

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.

NOTE, suggestion: cover a failed response with a complete verdict. This parameterization covers only empty/truncated text. The new docstring and implementation comment describe failed responses as parse failures, but a complete valid verdict with status="failed" still returns reward 1.0, parse_ok=True and an unmasked result on both base and head. The differential probe confirmed that behavior.

Could you add YES with those concrete expected values and the same single observation, and describe the available text as scored unchanged? Empty/truncated cases should keep their existing zeros. This protects gradable output rather than changing scoring policy.

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

The before-and-after cases preserved the rewards and masks. I’m requesting two changes to the failure reporting before merge. An attempt can acquire a scored marker even when it never reaches grading, and a single failed response can be counted twice or attributed to the wrong cause. The inline comments include reproductions for both.

if exported.return_code != 0:
# The idle check could not read the session, so the run is not nudged and is graded as it
# stands, as before; the failed export is recorded.
observe_scored_despite_failure(

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.

Blocker — emit scored_despite_failure only after grading succeeds. I made the idle export and the mandatory final export both return nonzero. This call recorded the event, then the final export raised opencode.export. The run never called /verify.

The same timing matters in both verifiers. With a failed policy response and an unreadable judge verdict, PerceptionBench returned mask_sample=True and failure_kind=judge_failed, yet the per-row health check reported it as scored despite failure. The agentic turn simulation judge did the same on its internal scoring-error path.

Could you keep the underlying failure as a diagnostic and apply the scored marker only once the attempt returns an unmasked score? A regression test should cover both a failed final export or masked verdict with zero scored markers, and a failed response with a usable answer that keeps its reward and records one marker.

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.

One smaller follow-up in the same idle check. A zero-byte or whitespace-only export.json becomes {} through json.loads(local.read_text().strip() or "{}"), so the parse-error handler never runs. I reproduced zero nudges and no event when the final export subsequently succeeded and the verifier returned 1.0. Could you let an empty download take the existing parse-error path? That keeps the zero nudges and records one failure on the graded run.

# mistaken for the model's own miss.
observe_scored_despite_failure(
boundary=FailureBoundary.RESOURCES_SERVER,
failure_kind=MODEL_REQUEST_ERROR,

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.

Blocker — preserve the originating failure kind and count the response once. I ran the single-agent environment and this verifier together with one unclassified failed response containing a correct answer. It earned 1.0, but the request recorded both agent_run_error from the environment and model_request_error from here. With a response explicitly classified as provider_oom_killed, the only scored event said model_request_error.

Could you have the environment and verifier agree on which one records a given failed response, and carry through its classified cause when available? Please cover the combined path as well as direct /verify so each produces one attributed event for a graded failure.

@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Dec 2, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer risk:mid Autobot PR risk: mid 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