Skip to content

fix(critpt_custom_grader): masked verdicts, scored wall-clock stops, continue after out-of-memory - #6808

Merged
Kipok merged 4 commits into
mainfrom
igitman/critpt-grader-masked-verdicts-oom
Nov 29, 2026
Merged

Kipok merged 4 commits into
mainfrom
igitman/critpt-grader-masked-verdicts-oom

Conversation

@Kipok

@Kipok Kipok commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Two critpt_custom_grader fixes for the agentic recipe (#5226), authored by @gwarmstrong, plus follow-ups from a pre-push review:

  • Unscored verdicts are masked results. The grader stopped writing rollout collection's _ng_failure_* keys, which collection refuses in an Environment Server result. An unscored verdict now names failure_kind and failure_reason, and records failure_outcome_action: fail for a terminal category, retry otherwise. An episode stopped at the agent's wall-clock limit without an accepted answer is now a scored no-answer, like the turn limit.

  • A command that exhausts memory no longer fails the episode. An OpenSandbox container is OOM-killed as a unit, so one code_exec command over the execution sandbox's memory limit ended the sandbox. The grader reported that as an infrastructure failure (HTTP 503), and recovery re-ran the whole episode. The provider confirms these deaths as provider_oom_killed, so the grader now returns an out_of_memory tool result, replaces the sandbox, and lets the episode continue. The message tells the model that files from earlier commands are gone. Other execution failures still end the episode.

  • Follow-ups.

    • A wall-clock no-answer stays scored as the model's result, but keeps failure_kind: agent_timeout with model attribution and no outcome action, as gdpval does, so recovery can still re-run a timeout whose window held an infrastructure fault.
    • A single finish the tool accepted before a wall-clock stop is graded.
    • A failed delete of an OOM-ended sandbox is retried when the session closes, instead of being left to the TTL.
    • Hosted-review follow-ups:
      • A wall-clock stop that lands after finish accepted an answer, while sibling calls of that response still run, loses the accepted turn from Stirrup's saved history. The runner now flags this (metadata.finish_accepted_unreported), and the grader keeps such an episode unscored and retryable instead of scoring a no-answer.
      • A request cancelled during the OOM-ended sandbox's delete leaves the session unusable, and its capacity is released once the delete finishes.
      • The agentic recovery command selects answer_source: finish_tool.
    • The README's recovery guidance now notes that a verifier_error row stops resubmit --recover, and that --rerun-masked-without-artifact also re-runs provider_unavailable rows.

On current main, 371 of the server's own tests fail. The masked-result change brings them back to green.

Validation

  • pytest resources_servers/critpt_custom_grader/tests in a fresh uv sync --frozen environment of the server:
    • current main: 371 failed, 1680 passed;
    • this branch: 2059 passed, 2 skipped.
  • pytest responses_api_agents/stirrup_agent/tests, in an environment synced from this branch: 218 passed. This includes a runner test that accepts finish, blocks a sibling code_exec, and cancels the run.
  • ruff check and ruff format (v0.9.9, the pre-commit pin) on the changed files.
  • Local review with Gym's protected-main rubric, three independent passes per round. It covered 58bda25f and then e7d4b6859532f4758bd5856add085601d89d32bc, which addresses the hosted review's BLOCKER and RISKs. Verdict SHIP. main moved during the last round; that move touched none of this PR's files. Advisory notes left open:
    • Re-running a timeout whose window held a fault needs a Store-backed (gym eval submit) run.
    • An empty answer accepted under a wall-clock stop is tagged agent_timeout.
    • There is no cap on OOM replacements per episode.
    • The recovery command loads the base grader config; reuse the producing run's configs (with their network policy and validators) where they differ.
      This does not replace hosted review or CI.

Rollouts

The agentic recipe at George's two commits (before the follow-ups) produced complete CritPt v2 runs for 15 model settings, open-weight and API models through vllm_model and openai_model: 70 problems × 5 repeats each, 5,250 episodes in all, with a 2-hour agent limit.

  • 9 episodes stopped at the wall-clock limit (5 of them from one model) and were graded as no-answers.
  • 49 episodes hit the execution sandbox's memory limit at least once and continued in a fresh sandbox. Before, each of them would have failed and been re-run from the start.

Reward profile, per model setting (70 problems × 5 repeats; temperature 1.0; 2-hour agent limit; 16 GiB execution sandbox; reward as graded during the run). "After" scores all 350 episodes. "Before" leaves out the affected episodes, which the base code masks: unscored wall-clock stops, and OOM episodes it fails and re-runs.

Model setting Wall-clock stops OOM episodes After: mean reward (n=350) Before: mean reward on unaffected (n) Affected episodes' mean
Kimi K3.1 Pro 0 3 32.3 32.6 (347) 0.0
DeepSeek V4.1 Flash 0 8 29.1 29.8 (342) 0.0
Claude Haiku 5.5 (max) 1 1 32.9 33.0 (348) 0.0
GPT-6 Astra (medium) 0 2 35.1 35.3 (348) 0.0
Nemotron 3.5 Super (self-hosted) 0 1 23.7 23.8 (349) 0.0
Nemotron 3.5 Super (hosted) 0 3 20.9 20.7 (347) 33.3
GLM-5.3 (max) 0 4 28.0 28.0 (346) 25.0
GPT-5.6 Sol (max) 1 3 33.4 33.8 (346) 0.0
GPT-5.6 Terra (max) 1 8 31.4 31.7 (341) 22.2
GPT-6 Luna (max) 0 1 27.7 27.5 (349) 100.0
GPT-6 Sol (max) 0 2 34.6 34.5 (348) 50.0
GPT-6.1 Sol (max) 1 1 35.7 35.9 (348) 0.0
GPT-6.1 Terra (max) 0 1 31.7 31.8 (349) 0.0
Grok 4.7 (xhigh) 5 2 27.1 27.7 (343) 0.0
Qwen3.8 27B 0 9 8.9 9.1 (341) 0.0

Every shift is within 0.7 points. Wall-clock no-answers score 0. OOM episodes that continued score 12.2% pooled, against 28.8% overall; for three settings they score above that setting's average. These runs used the profile's 2-hour agent limit and 16 GiB sandboxes, overriding the recipe defaults of 6 hours and 8 GiB. They predate the finish_accepted_unreported flag.

Compatibility and benchmark impact

  • A wall-clock stop without an answer now scores 0 and is tagged agent_timeout. Before, it was unscored, so runs that hit the limit will report lower scores with complete coverage.
  • An episode whose command exhausts memory now continues and is scored. Before, it failed and was re-run, so on memory-heavy problems coverage rises and scores can move.
  • Unscored verdicts are masked rows that keep the agent's response, so resume does not run them again. Run them through recovery (README, Recovery).
  • New Stirrup response metadata, finish_accepted_unreported, marks a stop that lost an accepted finish turn. The CritPt grader keeps such a row unscored (response_incomplete, retry). Other Stirrup consumers ignore the key.
  • Rows with unscored verdicts carry the masked-result fields in place of _ng_failure_*.

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs.
  • Tests added or updated and pass locally, or N/A for docs-only / non-code changes (so CI unit/server checks pass when applicable).
  • Documentation added or updated, or N/A with justification.
  • Pre-commit checks pass locally (pre-commit run --all-files) (so CI lint/format checks pass).
  • New source files include the required Apache-2.0 SPDX header.
  • All commits have DCO sign-off (git commit -s) (so the DCO check passes).

🤖 Generated with Claude Code

gwarmstrong and others added 3 commits November 25, 2026 11:40
… and grade wall-clock stops

Unscored verdicts no longer write rollout collection's _ng_failure_* keys, which
collection refuses in an Environment Server's result. They are masked results that
name failure_kind and failure_reason and record failure_outcome_action: fail for a
terminal category, retry otherwise. An episode stopped at the agent's wall-clock
limit without an accepted answer is now a scored no-answer, like the turn limit.

Signed-off-by: gwarmstrong <[email protected]>
…continue in a fresh sandbox

An OpenSandbox container is OOM-killed as a unit, so one code_exec command that exceeds the
execution sandbox's memory limit ends the sandbox. The grader reported that as an
infrastructure failure (HTTP 503), Stirrup failed the episode, and recovery ran the episode
again from the start.

The provider confirms these deaths as provider_oom_killed, which Gym's agent outcome policy
already treats as the model's result rather than a provider fault. The grader now answers
such a command with an out_of_memory tool result, replaces the sandbox, and lets the episode
continue; files from earlier commands are gone, and the message says so. Other execution
failures still end the episode as before.

Signed-off-by: gwarmstrong <[email protected]>
…etry ended-sandbox deletes

Follow-ups to the masked-result and out-of-memory changes:

- A no-answer at the agent's wall-clock limit stays scored as the model's
  result, but carries failure_kind agent_timeout and model attribution with no
  outcome action, as gdpval does. Gym's recovery can then run again a timeout
  whose window held a model-server, sandbox or tool-server fault, instead of
  counting it as a wrong answer.
- A single finish the tool accepted before a wall-clock stop is graded. The stop
  can land while sibling calls of the finishing response still run. A turn-limit
  stop with an accepted finish is still contradictory evidence.
- When deleting a sandbox the memory limit ended fails, the session keeps it and
  closing the session retries the delete, so its provider record is not left
  behind until its TTL.
- README: the verify contract of scored rows, when resume keeps a
  response_incomplete row, that a verifier_error row stops resubmit --recover,
  and that --rerun-masked-without-artifact also re-runs provider_unavailable
  rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Igor Gitman <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Nov 25, 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 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

I found one BLOCKER and three RISKs across the seven changed files and their callers. The collector-field change fixes the reserved-key rejection, but the wall-clock scoring change can silently score an accepted finish as a no-answer. Inline findings cover that defect, OOM cancellation handling, and the recovery example.

RISK: Add the required before/after reward profile

Could you add comparable reward-profile numbers for the CritPt v2 settings exercised here? The PR reports 5,250 episodes, nine wall-clock stops and 49 OOM-affected episodes, but no before/after mean pass@1 or scored/masked denominators. The wall-clock scoring change changes zero-score assignment, and OOM continuation changes which trajectories get resampled. Event counts show those paths ran; they do not show whether reward shifts are limited to the intended cases.

Please provide representative per-setting before/after mean pass@1 and scored/masked counts on comparable task/repeat identities, with model settings and limits stated. Separate the intended timeout/OOM deltas from unaffected outcomes and include the follow-up accepted-finish behavior. This supplies the fixed-benchmark reward evidence required by the review rubric without changing the intended scoring policy.

Validation

  • I reviewed all changed files with three delegated reviews and checked the reported findings against source and local probes.
  • Runtime: 766267172432.dkr.ecr.us-east-1.amazonaws.com/gym:54800b761ceea0f1b3b7d1a62b4008046207395b, a successful prior default-branch CI image. No head image was present, and the admitted base's build jobs were skipped. I installed Stirrup dependencies in a throwaway virtual environment outside the checkouts.
  • pytest resources_servers/critpt_custom_grader/tests: 2,053 passed, four failed, two skipped. The four failures were an OpenAI dependency mismatch introduced by review-environment setup. After pinning Gym's openai==2.45.0 in a separate environment, I reran exactly those four tests: four passed. Combined coverage was 2,057 passing tests; I did not rerun the entire suite after that repair. The two remote-only modules stayed skipped.
  • Base/head collector probes confirmed that base rejects the unscored reserved fields and head collects the replacement masked results. Timeout probes confirmed that clean timeouts and recorded infrastructure faults remain distinguishable. I reproduced the accepted-finish loss, OOM cancellation state and recovery-config mismatch described inline.
  • Head CI: Lint check, DCO, copyright, secrets detection and lock freshness passed; request was skipped. No head core/server-test results were available. Autobot PR risk #6808 failed with risk:unknown: grading failed; that is not a repository-test verdict.

I did not run live model rollouts or remote sandbox tests. The reward-profile counts above are author-reported, not independently reproduced.

Note: formal approval is not available for this request, so this review is posted as a comment only.


Inline comments (escaped v1):

  • responses_api_agents/stirrup_agent/sandbox_runner.py line 432: BLOCKER: Preserve the accepted finishing turn before scoring wall-clock no-answers. This cancellation path saves _completed_turns(), which reads the snapshot from the start of the current turn. Stirrup 0.1.12 can execute finish successfully and then block in a sibling tool call before appending that turn to history. The new wall_time scoring branch therefore turns lost submission evidence into a scored zero.

    I reproduced this with the actual runner/Stirrup loop, real /finish and /verify ASGI endpoints, and fake model/tool transport: /finish returned 200, a later code_exec blocked, and cancellation produced saved_output_items=[]. Verification returned candidate_no_answer, scored=true, reward=0, mask_sample=false, with zero grader calls. Base kept that same response unscored. This affects episodes whose accepted finishing turn is interrupted during a sibling call, not genuine no-answer timeouts.

    Could you preserve the current turn's assistant call and completed finish acknowledgement in the cancellation report, including the bound answer bytes? Until that evidence is available, do not treat a lost accepted submission as a clean no-answer. Add an integration test that accepts finish, blocks a sibling, cancels the real runner and verifies that the grader receives the accepted source. Keep a separate timeout with no accepted finish scoring zero. The new tests construct an intact finishing transcript, so they miss this producer path.

    Reproducer: python /workspace/review-probes/scoring-submission-1/runner_probe.py.

  • resources_servers/critpt_custom_grader/agentic_tools.py line 414: RISK: Abort the OOM replacement if its deletion wait is cancelled. CancelledError bypasses except Exception here and escapes from inside execute's exception handler, so _abort never runs. The shielded delete can finish while state.usable stays true and state.stop_task stays unset, with no replacement sandbox.

    I paused deletion, cancelled the command, then let deletion finish using the real AsyncSandbox facade and a fake provider. The provider had no live sandbox, but replaying the seed succeeded; the next command failed with execution_provider_failed. With max_sessions=1, a different episode received execution_capacity_exceeded. A disconnected request can therefore leave dead capacity occupied until another command, explicit close or expiry.

    Could the whole replacement operation retain ownership of the old stop task before its first await, mark the session unusable and perform the existing abort cleanup on cancellation before re-raising? Preserve normal OOM continuation and deferred retry of ordinary failed deletes. Test cancellation during old-sandbox deletion: seed replay must not advertise a usable dead sandbox, and another episode must reclaim capacity once cleanup completes. Also keep delayed-create cancellation and failed-delete retry coverage green.

    Reproducer: python /workspace/review-probes/oom-lifecycle-1/cancel_delete_probe.py.

  • resources_servers/critpt_custom_grader/README.md line 562: RISK: Select finish-tool grading in the agentic recovery example. The rewritten instructions now select masked agentic rows, but this inherited command loads critpt_custom_grader.yaml, whose default is answer_source: output_text. Its validator rejects the saved agentic input's tools, so the advertised recovery cannot grade those answers.

    I built a payload from a saved acknowledged finish with the actual _build_verify_payload and sent it through /verify: output-text mode returned HTTP 422 without grading; finish-tool mode returned HTTP 200 and passed the exact submitted source to the grader. The command/config mismatch already existed on base; this PR changes the surrounding workflow to direct masked agentic results through it, rather than introducing a new parser defect.

    Could the recovery command retain the producing run's grading settings and explicitly select answer_source: finish_tool, through a recovery config or override? Do not remove tools to bypass validation, because that can select assistant text instead of the acknowledged answer. Check that a saved agentic rollout reaches the grader with finish.answer and that aggregation substitutes its recovered identity exactly once.

    Reproducer: python /workspace/review-probes/docs-tests-contracts-1/readme-reverify.py; observed output_text: 422, finish_tool: 200.

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

…a cancelled OOM replacement

Hosted review of #6808:

- Stirrup's runner reports the history as of the start of the running turn
  when it is stopped. A stop that lands after the finish tool accepted an
  answer, while other calls of that response still run, loses the accepted
  turn. The runner now records accepted finish calls and the agent server sets
  metadata.finish_accepted_unreported for such a stop; the grader keeps that
  episode unscored (response_incomplete, retry) instead of scoring a no-answer.
- A request cancelled while the OOM-ended sandbox is being deleted leaves the
  session unusable with that delete as its stop, so a replayed seed cannot
  revive the dead sandbox and the reaper or a close releases its capacity once
  the delete finishes.
- README: the agentic recovery command selects answer_source finish_tool, and
  the lost-finish case is documented.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Igor Gitman <[email protected]>
@Kipok

Kipok commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Addressed in e7d4b68:

  • BLOCKER (lost accepted finish): the Stirrup runner now records when a finish tool accepts a call. On a stop whose reported history lost that turn, the agent sets metadata.finish_accepted_unreported, and the grader keeps the episode unscored (response_incomplete, retry) instead of scoring a no-answer. test_a_stop_after_an_accepted_finish_reports_that_the_answer_was_lost runs the real runner: it accepts finish, blocks a sibling code_exec, and cancels. test_a_stop_that_lost_an_accepted_finish_is_not_scored_as_a_no_answer covers the grader side. A timeout without an accepted finish still scores 0 (agent_timeout). I took the masking route rather than rebuilding the lost turn from the observer.
  • RISK (cancel during the OOM-ended delete): on CancelledError the session becomes unusable and keeps the in-flight delete as its stop, so a replayed seed cannot revive it, and the reaper or a close frees the slot once the delete finishes. test_a_request_cancelled_during_the_ended_sandbox_delete_leaves_no_usable_session checks: no replacement, the seed conflict, the capacity refusal, then capacity reclaimed.
  • RISK (recovery command): it now selects answer_source: finish_tool for agentic rows.
  • RISK (reward profile): the description has per-setting before/after mean reward and denominators for 15 model settings. Every shift is within 0.7 points.

Tests: critpt_custom_grader 2059 passed, stirrup_agent 218 passed, ruff clean.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the ready-to-merge PR is approved, current, and waiting for final CI or merge label Nov 26, 2026
@Kipok

Kipok commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test e7d4b68

@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 29, 2026 16:54
@Kipok
Kipok added this pull request to the merge queue Nov 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

Merged via the queue into main with commit d352586 Nov 29, 2026
69 of 70 checks passed
@Kipok
Kipok deleted the igitman/critpt-grader-masked-verdicts-oom branch November 29, 2026 17:28
yfw added a commit that referenced this pull request Nov 30, 2026
#5010 merges main a6f6362, which brings #6808's finish-accepted report into the Stirrup runner and agent. Two
conflicts, both where this layer and #6808 changed the same lines: the response metadata in app.py, which now
keeps this layer's stop_reason swap and #6808's finish_accepted_unreported flag, and the runner tests, which keep
both sides' tests. The next commit adjusts #6808's test and the empty stopped report to this layer's stop report.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
yfw added a commit that referenced this pull request Nov 30, 2026
…op report

#6808 assumed that a stopped run reports the history as of the start of the running turn, so a finish that the
tool accepted during that turn was missing from the output. With this layer, a stopped run reports the running
turn's reply, so the finish call is in the output, but its answer is not. The CritPt grader accepts a finish only
with its answer, so finish_accepted_unreported still applies, and graders still keep such an episode unscored.

The runner comments now say that the answer is missing, not the turn. #6808's test checks that the finish call
has no answer. The empty report for a run that a stop ended before any output carries finish_accepted: false, as
the runner's report does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge PR is approved, current, and waiting for final CI or merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants