Repository navigation
feat(critpt_custom_grader): add agentic recipe, semantic validators and opt-in Stirrup overflow recovery - #5226
Conversation
Signed-off-by: Erik Arakelyan <[email protected]>
Signed-off-by: Erik Arakelyan <[email protected]>
Signed-off-by: Erik Arakelyan <[email protected]>
Signed-off-by: Erik Arakelyan <[email protected]>
Integrate the fix and error regression coverage from NVIDIA-NeMo#5383: 31b36e3 and b4dd15e. Apply the scored-zero outcome to output_text responses and preserve the agentic finish-tool precedence for infrastructure and invalid evidence. Add regressions for finish-tool handling and malformed request metadata. Co-authored-by: Igor Gitman <[email protected]> Signed-off-by: Igor Gitman <[email protected]> Signed-off-by: Erik Arakelyan <[email protected]>
|
/ok to test 7fe223a |
|
/review |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE — one RISK: mixed-language fences can cause a valid acknowledged Python submission to be extracted incorrectly and scored zero.
Completed the broad review across all 27 changed files and their affected grading, session, provider, and trajectory contracts. The PR supplies representative real-smoke evidence. This review was static; no tests or rollouts were executed.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
Signed-off-by: Erik Arakelyan <[email protected]>
Signed-off-by: Erik Arakelyan <[email protected]>
Signed-off-by: Erik Arakelyan <[email protected]>
Signed-off-by: Erik Arakelyan <[email protected]>
Merge main at 330c461 into the agentic CritPt branch. Where main has since added its own handling for something this branch also changed, the merge keeps main's version: - responses_api_models/vllm_model is identical to main. The exact completion fitting is dropped; main's refit_output_budget_to_prompt (NVIDIA-NeMo#5864) covers what the agentic recipe needs. - Stirrup compaction failure uses main's handling (NVIDIA-NeMo#5822) and its max_turns stop reason (NVIDIA-NeMo#5937). In finish_tool mode the grader scores an agent_invalid_output response zero as candidate_no_answer. - Context-overflow recovery becomes the opt-in Stirrup option context_overflow_recovery (default false). The runner reports the model server's own rejection. - The grader's execution sessions use ResourcesSessionLocks and ResourcesSessionFences (NVIDIA-NeMo#5083); agentic_execution refuses several workers (NVIDIA-NeMo#4790). - A semantic validator failure or timeout stays unscorable with score_comparator_uncertain_as_incorrect (NVIDIA-NeMo#5416). - nemo_gym/ is unchanged. Two fixes found while validating the merge: - Since NVIDIA-NeMo#5128 the single_agent_turn environment servers and the agents that verify through verify_agent_response send failure_report with every /verify request. The grader read it as an unknown task field and answered task_invalid for every such rollout; it is now a framework field. - tests/test_runner_remote.py built ExecutionPolicy with four arguments the policy does not have and expected a 2 GiB address-space limit it never set, so nine of its tests failed; both are corrected. Also included: fixes from a review of the merged diff (session glossary wording, main's lost-session body on /code_exec, tighter execution limits, a stopped session releasing its capacity slot, route tests, and a local end-to-end grade of a semantic-validator task). Signed-off-by: Erik Arakelyan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
A clean merge. Main's NVIDIA-NeMo#6140 (the Stirrup client's per-image token estimate) changes four files this branch also changes, in other lines; neither side's changes are altered. It also brings main's repaired secrets baseline (NVIDIA-NeMo#6083). Signed-off-by: Erik Arakelyan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
I merged main into this branch; the new head is This head also fixes a problem on main. Since #5128, the Could a maintainer please, in this order:
Two questions:
|
Main's NVIDIA-NeMo#5899 removes the grader's request and response byte caps. It conflicts with this branch in the grader's app.py, README.md and tests/test_app.py; its task_data.py change merges cleanly. The merge takes main's cap-free request handling, also for /finish and /code_exec, and drops agentic_max_response_bytes, which set those caps in finish_tool mode: the config field, its line in the agentic recipe and the three tests that exercised it. The command, output, source and semantic-validator limits stay. Main's NVIDIA-NeMo#5691 (the Stirrup agent's app.py) and NVIDIA-NeMo#5720 and NVIDIA-NeMo#5780 (scripts/component-lock-policy.json) change files this branch also changes, in other lines; neither side's changes are altered. Signed-off-by: Erik Arakelyan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main's NVIDIA-NeMo#5997 makes output_dir a required keyword-only argument of TrainDataProcessor._collate_samples_single_type. The agentic recipe test calls it directly, so it now passes tmp_path / "prepared", as main's own tests do. Signed-off-by: Erik Arakelyan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main's NVIDIA-NeMo#6165 adds a resources_servers/ether0 entry to scripts/component-lock-policy.json next to this branch's resources_servers/critpt_custom_grader entry. Both entries are kept, in sorted order. Main's NVIDIA-NeMo#5597 changes no file this branch changes. Signed-off-by: Erik Arakelyan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
/ok to test a969829 |
|
/review |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP — the prior finding is fixed, and I found no new regression eligible under the follow-up policy.
The reported mixed-language-fence example now selects only the final Python source. The extractor consumes complete blocks before filtering their languages. The regression tests cover unsupported blocks around accepted answers and retain raw-answer fallback and empty-answer behavior.
I compared the subsequent changes with reviewed head 7fe223a755c173e530eac5d6f97d3ed088a8cd0c across grader scoring, execution-session isolation and Stirrup recovery, then traced their affected contracts and tests. No unresolved prior finding or proven introduced high- or critical-impact regression remains in that scope. This was a follow-up review using the historical moderate-impact threshold, not a fresh whole-PR review.
This review was static. I did not execute tests, build images or run rollouts. Dependency inspection covered declared dependencies and lock-policy metadata, not every transitive lockfile artifact.
Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/44202337859 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/44206460880 |
What does this PR do?
Extends
critpt_custom_grader(#4629) with two opt-in features, adds one opt-in option to the Stirrup agent, and fixes how the grader readsfailure_report(item 4). Apart from that fix, grading with the default configuration (answer_source: output_text, noagentic_execution, nosemantic_validators) behaves as on main.1. Agentic recipe (
configs/critpt_custom_grader_agentic.yaml). It composes the grader with the Stirrup agent:/code_execruns the model's commands in a per-episode Linux sandbox whose provider configuration must deny network egress. The server refuses to start on a configuration that does not establish that, and the sandbox provider enforces it. Files persist for the episode, and the sandbox receives no task data.ResourcesSessionLocksandResourcesSessionFences. A server withagentic_executionruns with one worker.code_execis off. Its orchestration sandbox keeps network access, because it must reach the model and Gym.finish(reason, derivation, answer). Withanswer_source: finish_toolthe grader grades only the acknowledgedfinish.answer, in the grader's isolated reference, candidate and comparison sandboxes.max_output_tokensor on a content filter without an acceptedfinish, and Stirrup'scompaction_failedoutcome score zero. Provider failures, wall-clock stops, cancellations and rejected model requests stay unscorable. Malformed, duplicate or contradictory finish evidence issubmission_invalid: unscorable and terminal.The recipe provides the execution and submission mechanisms that Artificial Analysis's published CritPt v2 methodology describes: Stirrup, an offline Linux Python 3.13 environment with NumPy, SciPy, SymPy and Matplotlib, up to 50 turns, a structured
finishtool and five repeats. The operator supplies the images and the model settings. The README separates the published requirements from this recipe's own package pins and limits. This PR does not claim equivalence with Artificial Analysis's generation or grading and calls no external grading API.2. Semantic answer validators. A task with several valid answers can select an operator-registered validator. It receives decoded values, the original inputs and bounded JSON configuration, and runs in the protected comparator sandbox under resource limits and per-case deadlines. The same predicate checks the reference outputs before any candidate runs. After a successful reference preflight, a candidate the validator rejects scores zero, unless the validator fails or times out on another case of the same task, which leaves the row unscorable. An invalid reference, a validator exception, a non-Boolean return and a timeout stay unscorable, also with
score_comparator_uncertain_as_incorrectset. The examples are synthetic; the mechanism supplies no benchmark's acceptance policy.3. Stirrup:
context_overflow_recovery(defaultfalse). With it on, an HTTP 400 or 413 rejection whose error object carries the codecontext_length_exceededlets Stirrup drop the latest completed turn and send the request again. When Stirrup can drop no further turn (it keeps the task, everything up to the latest compaction summary and at least one completed turn after it), the episode ends with the model server's own status and message. The CritPt recipe turns the option on and documents the twovllm_modelsettings it relies on,propagate_context_overflow_errorsandrefit_output_budget_to_prompt. The recipe cannot set them, because the model server is the operator's; withvllm_modeldefaults the rejection never reaches the agent and nothing is recovered.4. Fix: a verify request that carries
failure_report. Since #5128, thesingle_agent_turnenvironment servers and the agents that verify throughverify_agent_responseaddfailure_reportto every/verifyrequest they send. The grader reads every field it does not own as task data and its task schema forbids unknown keys, so on main it answerstask_invalidfor every rollout verified that way, its default recipe (throughsingle_agent_turn_legacy) included. The grader now treatsfailure_reportas a framework field. The new testtest_failure_report_of_the_verify_request_is_not_task_datafails on main and passes here.Two supporting Stirrup edits are not behind the option and change nothing while it is off: a failed compaction reports the history as it was before any overflow drop, and the runner's
Observerkeeps a reference to each tool message it records, so a dropped message's identity is never reused.Tests and docs: new grader suites
test_agentic_recipe.py,test_agentic_tools.py,test_submission.py,test_semantic_execution.py,test_semantic_end_to_end_local.pyandtest_semantic_runner_remote.py, with additions to the grader's and the Stirrup agent's suites and to the core task-data test. The grader README gains "Agentic code execution" and "Semantic answer validators"; the Stirrup README gains "Context overflow recovery".No separate issue: this continues #4629.
Changes since the previous head (
bb4549a7), after merging mainAll of them are in
d5f2839c19a42e0ce7be184fdcbfd7567ed8d629, the merge of main intobb4549a7, and in no earlier commit. The head,b7cb8c5a6c82d7194201005019d4304f980891d6, then merges main at951ee9ecwithout conflicts and changes none of the PR's lines. Please review the PR's diff against main; the list below is what this PR changed sincebb4549a7. That commit's diff againstbb4549a7, limited to the PR's files, also contains main's own changes to those files, for example #5416 and #4790 in the grader'sapp.py. Three earlier branch commits (24494ebc0,302caa1a1,8005d6665) add code that this merge removes or reworks.configs/critpt_custom_grader.yaml,nemo_gym/data/__init__.py, Stirrup'stests/test_sessions.pyandvllm_model'sapp.pyandREADME.mdare identical to main again, andvllm_model'stests/test_context_budget.py, which the previous head added, is removed.tests/test_semantic_end_to_end_local.pyis new and grades a synthetic semantic-validator task through thelocalprovider, andtests/test_runner_remote.pynow differs from main (see below).fit_completion_to_contextis dropped; main'srefit_output_budget_to_prompt(feat(vllm_model): opt-in refit of the output budget to the prompt #5864) covers what the recipe needs.finish_toolmode the grader scores a failed response that the agent classifiedagent_invalid_output, which is how Stirrup reportscompaction_failed, zero ascandidate_no_answer, and a resumed run does not generate it again. The previous head left that outcome unscored.max_turnsstop reason: main's (fix(stirrup): report a run that exhausts its turns as stop_reason max_turns #5937).codeof the OpenAI error object; thedetail-envelope branch is removed.ResourcesSessionFenceto main'sResourcesSessionLocksandResourcesSessionFences(refactor(sessions): one name per session lifecycle concept before release #5083). The server keeps its own seed and close for these sessions and passescheck_resources_session_contractwithkeeps_state=True. Several workers (feat(server): run every server that can with several workers #4790) are refused whenagentic_executionis set./code_execerrors: a lost or expired resources session answers 404 with Gym's lost-session body (detail.failure_kindissession_lostorsession_expired) instead of{"detail": "session_unavailable"}.agentic_execution.max_command_bytesis capped at 64 KiB (was 1 MiB). A command whose shell-quoted form exceeds 127 KiB gets a repairableinvalid_argumentresult. The E2B offline check also refusescreate.networkandcreate.custom_extension_params. A session whose sandbox has already stopped gives back itsmax_sessionsslot.execution.job_timeout_sapply only to a server that configuressemantic_validators. A validator failure or timeout stays unscorable withscore_comparator_uncertain_as_incorrect(fix(critpt): allow terminal zero scores for comparator uncertainty #5416) set.finish_toolmode:agentic_max_response_bytesis unchanged; its lower bound isMAX_RESPONSE_BYTES, and in that mode the request limit is2 * MAX_TASK_BYTES + 2 * agentic_max_response_bytesin place ofMAX_REQUEST_BYTES. The PR's streaming rewrite of_read_jsonis replaced by main's whole-body read with the mode's limit. fix(critpt): remove grader-specific request and response byte caps #5899, which is open, removesMAX_RESPONSE_BYTES,MAX_REQUEST_BYTESand the 413request_limitpath; if it lands first I will drop the option, its line in the recipe YAML and the/finishand/code_execbody limits that depend on them.tests/test_runner_remote.pybuiltExecutionPolicywith four arguments the policy does not have (snapshot,os_user,owner_id,journal_dir) and expected a 2 GiB address-space limit without setting it. Those lines are unchanged from main, so nine of its tests fail there too when the suite runs. This PR removes the four arguments and setsmemory_limit_mib=2048in that one test, so the job-size boundary tests now exercise the runner code this PR changes.failure_reportin verify requests: the fix described in item 4, found by the first real-model run of the recipe on an earlier merge of main (see the end of Rollouts).nemo_gym/.Validation
On the tree of
b7cb8c5a6c82d7194201005019d4304f980891d6, which merges main at951ee9ec835dde26c32302dcb86bcf0ed445bf4d, unpacked from a source archive on Linux (aarch64), with the repository's CI scripts and the commands of its workflows:./scripts/ci/lint.sh: passed with no file modified. The guardwords hook had no catalog available and skipped, so guardwords are left to the repository's own check.uv run --no-project --python 3.13.14 python scripts/component_locks.py: all 303 projects passed.detect-secrets-hook --baseline .github/workflows/config/.secrets.baselineon the PR's files: passed against main's baseline at951ee9ec../scripts/ci/core_unit_tests.sh <0..3> 4: 22,384 passed, 116 skipped. Sandbox tests (pytest --cov=. --cov-report= --cov-fail-under=0 --durations=10 -m sandbox): 1,557 passed, 7 skipped. None of the skips is in a test this PR adds or changes.scripts/ci/combine_core_coverage.py: 95.08 % (gate 95 %).gym env test +entrypoint=resources_servers/critpt_custom_grader +should_validate_data=true: 2,047 passed, 2 skipped. The two skips are two whole modules,tests/test_runner_remote.pyandtests/test_semantic_runner_remote.py, which run only withNG_CRITPT_RUNNER_REMOTE=1inside a disposable non-root sandbox.d5f2839c(this head leaves the grader's files unchanged), each in a disposable container built fromruntime/Dockerfilewith no network, a non-root user, no capabilities and a read-only root, withNG_CRITPT_RUNNER_REMOTE=1set only inside the container:tests/test_runner_remote.py157 passed,tests/test_semantic_runner_remote.py16 passed.b02f8d09(main's grader is unchanged since) with only the newfailure_reporttest added: both cases of that test fail (task_invalidinstead ofpassed), 1,828 other tests pass and 1 is skipped.gym env test +entrypoint=responses_api_agents/stirrup_agent +should_validate_data=true: 214 passed.gym env test +entrypoint=responses_api_models/vllm_model +should_validate_data=true: 1,197 passed.gym env test +entrypoint=resources_servers/gdpval +should_validate_data=trueandgym env test +entrypoint=resources_servers/aa_briefcase_lite +should_validate_data=true, the two other components whose tests read the Stirrup agent's files: 969 passed, 2 skipped; and 97 passed.scripts.harness_conformance.ci install, the conformance and adapter tests,scripts/run_harness_conformance.py --harness stirrup): 690 tests passed, 14 skipped; all nine probe scenarios fulfilled, with no difference from main run side by side on the same machine.Not run locally: the eight-shard server suite (
./scripts/ci/server_tests.sh), which CI runs for this diff because it also touchesscripts/andtests/. It needs CI's shared test data and system packages.Rollouts
One real-model run on the tree of
d5f2839c, the merge before this head (this head adds only main's newer commits; the PR's own changes are identical): the shipped synthetic example through the shipped agentic recipe, with the README's command (gym eval run --no-serve --agent critpt_custom_grader_stirrup_agent --input resources_servers/critpt_custom_grader/data/agentic_example.jsonl --prompt-config resources_servers/critpt_custom_grader/prompts/agentic.yaml --num-repeats 5 --output …) plus overrides for the head-server address, observability and model-call capture, one attempt per rollout.Qwen/Qwen3.8-27B, served by vLLM 0.28.0 (vllm/vllm-openai:v0.28.0) with data parallelism 4, a 262,144-token context, MTP speculative decoding, theqwen3_codertool parser and theqwen3reasoning parser. Thinking on, temperature 1.0, top-p 0.95.vllm_modelwithpropagate_context_overflow_errors: trueandrefit_output_budget_to_prompt: true, as the recipe's README asks. The agent asked for the whole window (min_completion_tokens=max_completion_tokens_cap=context_window_tokens= 262,144).dockerprovider, through a rootless Podman command wrapper, in place of the recipe's OpenSandbox provider. The execution and grading sandboxes had no network: a probe in each image, run with--network none, saw only the loopback interface, could not open an outbound connection, and ran as uid 1000. The orchestration sandbox used host networking, so it could reach the model and Gym as the recipe requires. The execution image provided Python 3.13.14 with NumPy 2.5.1, SciPy 1.18.0, SymPy 1.14.0 and Matplotlib 3.11.0.Result: all 5 rollouts were scored and unmasked, each with reward 1.0 (
passed). Every episode ended with one accepted and acknowledgedfinish, after onecode_execcall in which the model tested its function, including integers above 64 bits; all 5 commands exited 0. vLLM refused the first request of each of the 10 model calls with HTTP 400, because 262,144 output tokens plus the prompt exceed the window;vllm_modelrefitted the budget to 260,751–261,222 tokens and resent it, and all 10 calls were answered with HTTP 200. There were no failure rows, and cleanup resolved with no container left.Not exercised: compaction and context-overflow recovery, since each episode took two model calls. The Stirrup tests above cover both.
The first run of this recipe, on an earlier merge of main into this branch without the fix, found the
failure_reportproblem (item 4): the grader refused all five episodes astask_invalid.Compatibility and benchmark impact
answer_source: output_text, noagentic_execution, nosemantic_validators): apart from thefailure_reportfix (item 4), which grades rollouts that main answerstask_invalid, grading results, request limits, timeouts and error bodies are unchanged, andconfigs/critpt_custom_grader.yamlis identical to main. Two more things change for every deployment:runner.pyandtask_data.py, which this PR edits. A cache persisted withreference_cache_dirby an earlier build is recomputed once; grading results do not change. The shipped config does not persist the cache.stirrup==0.1.12andPillow==12.3.0(with apillowoverride recorded inscripts/component-lock-policy.json). Both are already used byresponses_api_agents/stirrup_agent, and they are imported only when/code_execruns.task_invalid(item 4). Only the new recipe setsanswer_source: finish_toolorcontext_overflow_recovery. The recipe isverified: falseand ships a one-row synthetic example, not a benchmark release or a baseline.finish_toolmode: the grader takes the last fenced block offinish.answerwhose info string is empty orpython, else the whole answer. The recipe's dataset setsnum_repeats: 5: the result is the mean of five independently scored attempts per task; there is no best-of-five credit. Infrastructure failures stay unscorable and must be reported as incomplete coverage. A rejected model request isresponse_incompleteand not terminal, so resuming the run generates that attempt again.execution.job_timeout_sbelow a higher minimum: with the shipped limits it rises from 9595 s to 9725 s, so the default config's 9700 s has to be raised before validators are added to it (the agentic recipe sets 9800 s). The comparison of a task that selects a validator setsRLIMIT_FSIZEto 161,546,240 bytes instead of 156,303,360. A validator owns its acceptance rule and numerical tolerances.context_overflow_recoverydefaults tofalse; existing configurations are unaffected. With it on, a dropped turn is absent from the output items, but its model call, token usage and tool executions stay in the reported evidence, and whatever its commands changed in the sandbox stays changed. A dropped turn no longer counts againstagent_max_turns, so only the agent's wall-clock limit (sandbox_runner_timeout_seconds, or a task row's shorter timeout) bounds repeated recovery.New configuration keys, categories and prerequisites
answer_source(output_text),agentic_execution(unset; requiresanswer_source: finish_tool),agentic_max_response_bytes(32 MiB, 1 MiB to 128 MiB, read only infinish_toolmode) andsemantic_validators(empty; at most 64 validators, 256 KiB of source each); task fieldsemantic_validator: {id, config}(config at most 16 KiB, value expectations only); underagentic_execution:sandbox_providerandsandbox_spec.image(required),command_timeout_s(300),provider_timeout_margin_s(60),max_command_bytes(65536, also its maximum),max_output_bytes(1 MiB),max_sessions(16),create_timeout_s(600),close_timeout_s(60); Stirrupcontext_overflow_recovery(false)./verifyinfinish_toolmode addscandidate_no_answer(scored zero) andsubmission_invalid(unscorable, terminal), and itsrequest_limitthreshold becomes 8 MiB plus twiceagentic_max_response_bytes(72 MiB by default).task_invalidalso covers asemantic_validatoridentifier the server has not registered./seed_sessionwithagentic_executionanswers 422session_identity_required, 409session_conflict, 503execution_unavailableand 503server_not_ready./finishanswers 422invalid_finish./code_execanswers 422invalid_code_exec, 404 with Gym's lost-session body and 503execution_unavailable.runtime/Dockerfile), the execution image (runtime/agentic/Dockerfile) and an orchestration image, and setsCRITPT_CUSTOM_GRADER_IMAGE,CRITPT_AGENTIC_EXECUTION_IMAGEandCRITPT_AGENTIC_ORCHESTRATION_IMAGE. The execution sandbox starts only on a provider whose configuration establishes no egress: OpenSandbox with a deny-all network policy (the shipped recipe), Docker withnetwork: none, or E2B with internet access off. Every other provider is refused at startup.Proposed labels:
feature,area:environment, andneeds-review.CI note: the commits are not cryptographically signed, so the mirrored CI needs a maintainer to comment
/ok to test b7cb8c5a6c82d7194201005019d4304f980891d6with the full 40-character SHA.Checklist
pre-commit run --all-files) (so CI lint/format checks pass).git commit -s) (so the DCO check passes).🤖 Generated with Claude Code