Repository navigation
build(deps): upgrade all managed dependency locks - #6528
Merged
Merged
Conversation
The locks added for every environment were seeded from the root uv.lock, which had not been upgraded since the repository was imported in September 2025. About half of the locked packages were older than what an unpinned install resolved before the locks existed, including pandas 2.3.2, which slowed the workplace_assistant environment by about 20% in NeMo RL GRPO runs. Add --upgrade to scripts/component_locks.py and run it on every managed project. Cap the two SDKs whose newer releases need Gym changes: - ray <2.60: Ray Serve 2.60 imports grpc_reflection without declaring it, and grpcio-reflection needs protobuf 7, which conflicts with vLLM. - e2b <2.51: 2.51 stopped defaulting pause() to keep memory, and 2.52 removed the transport hook the e2b provider replaces. Update MCP tests to use wire field names and the streamable_http_client API, which both MCP 1 and MCP 2 support. Signed-off-by: Ananth Subramaniam <[email protected]>
ananthsub
force-pushed
the
ananthsub/upgrade-locks
branch
from
November 20, 2026 01:44
aa70459 to
f5c1ff2
Compare
The lock upgrade moves pytest-asyncio to 1.5, starlette to 1.10 and the root environment to MCP 2. Three tests depended on the old behavior: - spider2_lite: asyncio.get_event_loop() no longer returns a loop in the main thread after pytest-asyncio tests, so use asyncio.run() - aa_briefcase_lite: starlette's TestClient is now an httpx2.Client, which the OpenAI SDK rejects; route an httpx.Client through it - session routing e2e: the tool_counter fixture used MCP 1's streamablehttp_client and isError; use streamable_http_client with the client package the installed MCP takes, and read wire field names Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: oliver könig <[email protected]>
ko3n1g
approved these changes
Nov 20, 2026
ko3n1g
enabled auto-merge
November 20, 2026 09:35
marta-sd
approved these changes
Nov 20, 2026
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/44738781135 |
7 tasks done
7 tasks done
3 of 4 tasks
7 tasks done
abelatnvidia
added a commit
to abelatnvidia/Gym
that referenced
this pull request
Nov 20, 2026
Brings the branch up to date with main. The only conflict was resources_servers/bird_sql/uv.lock, which main's lock upgrade (NVIDIA-NeMo#6528) rewrote. Resolved by taking main's lock and re-locking with uv 0.13.4, the version CI uses: every version main locks is kept, and the Snowflake dependencies are added at the versions this PR already tested (fakesnow 0.12.1, snowflake-connector-python 4.8.1, duckdb 2.0.0, boto3 and botocore 1.44.5, and their dependencies). Two of main's versions move down because those dependencies require it: sqlglot 30.33.0 -> 30.22.0 (fakesnow pins ~=30.22.0, as before) and python-dateutil 4.0.0 -> 2.9.0.post0 (botocore requires <3, through the Snowflake connector). scripts/component_locks.py passes for all 327 managed projects. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Abel Brown <[email protected]>
copy-pr-bot Bot
pushed a commit
that referenced
this pull request
Nov 21, 2026
main's #6528 upgraded every managed dependency lock. The four uv.lock files this branch also changed (lvbench, video_mcqa, videomme_v1, videomme_v2) take main's version here; a later commit relocks them for this branch's dependencies. Signed-off-by: Guo Chen <[email protected]>
copy-pr-bot Bot
pushed a commit
that referenced
this pull request
Nov 21, 2026
… main Relocked with uv 0.13.4 on top of main's upgraded locks (#6528): lvbench, video_mcqa, videomme_v1, videomme_v2 and video_qa_rubric. Each lock only gains the packages of this branch's dependencies (nemo-gym's sandbox extra, and pillow 12.3.0 in video_mcqa); python-dateutil is 2.9.0.post0 again, as in main's other locks with the sandbox extra. Signed-off-by: Guo Chen <[email protected]>
d-molinari
added a commit
that referenced
this pull request
Nov 21, 2026
Main's lock upgrade (#6528) moved the root lock, and `uv sync --locked` refused the sandboxed server's older lock, so neither its suite nor a run could start it. `uv lock` with uv 0.13.4 takes the root lock's versions (e2b 2.50.0, protobuf-py 0.1.1, pyqwest 0.10.0), keeps the tzdata OfficeEnv pins (2026.6), and passes scripts/component_locks.py. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]>
d-molinari
added a commit
that referenced
this pull request
Nov 21, 2026
Main's lock upgrade (#6528) moved the root lock, and `uv sync --locked` refused the sandboxed server's older lock, so neither its suite nor a run could start it. `uv lock` with uv 0.13.4 takes the root lock's versions (e2b 2.50.0, protobuf-py 0.1.1, pyqwest 0.10.0), keeps the tzdata OfficeEnv pins (2026.6), and passes scripts/component_locks.py. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]>
yaoyu-33
added a commit
to cg1177/Gym
that referenced
this pull request
Nov 21, 2026
…video QA on stock opencode_agent, with Video-MME v2 / Video-MME agentic benchmarks (NVIDIA-NeMo#6315) * refactor(video): import nemo_gym names from their public packages The four video servers and their tests imported the pre-0.8 module paths (nemo_gym.base_resources_server, config_types, global_config, openai_utils, server_utils), which still import with a deprecation warning. They now import each name from its package's public API, as scripts/migrate_imports.py writes it; `migrate_imports.py --check` reports nothing for these folders. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * feat(video): optional judge-model answer extraction for Video-MME v2, Video-MME and LVBench Add answer_policy llm_extraction_v1 to the shared video MCQA scoring. A judge model (any OpenAI-compatible chat model behind a Gym model server, called through call_judge on /v1/chat/completions) reads which option a final answer gives; the verifier scores that option against the gold label. The judge sees the prompt's text (no media) and the final answer (no reasoning), never the gold label. - A "none" reading is the new outcome no_choice (a measured zero); an empty final answer stays no_answer and is not sent. - A failed judge call or a reply that names no option raises a judge failure: Gym's judge failsafe masks the row and keeps it with its answer in the failures file, so the frozen cohort counts the task as missing until it is judged again. - The judged grading, verify response included, runs in observe_llm_judge_grading, so Gym binds the graded response and reward to the judge's reply. - The cohort declares the policy; a server whose cohort uses it refuses to start without judge_model_server. The rule policies stay the default and never call a judge. - prepare_single_turn and prepare.py take a prompt style: boxed (default) or the benchmark's bare-letter prompt (videomme_v2, videomme_v1, lvbench). - New configs <benchmark>_single_turn_llm_extraction.yaml for the three benchmarks: the single-turn config plus an openai_model judge (judge_base_url, judge_api_key, judge_model_name). Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(video): sandbox image with frame-sampling video tools for OpenCode Adds resources_servers/video_mcqa/sandbox_image: a Dockerfile and the video tools it installs in /opt/video-mcqa. - video_tools.mjs: an OpenCode 1.17.11 plugin with watch_video and view_image. It runs `python3 -I -m video_tools.cli` once per call and returns the images as tool attachments. It also caps the tool images that one episode sends (400 MiB of base64 by default): from the result that would pass the cap on, results show a notice in place of their images, the same in every request. The tools take plain JSON Schema arguments, so the plugin imports only Node's standard library. - video_tools: watch_video samples the center of each of num_frames equal bins of [start, end), takes the latest source frame not after each sampling time, resizes by area to the requested long edge rounded down to the model's grid (patch_size / downsample_ratio, 28 px by default) and returns JPEG frames (quality 95, 4:4:4) with "This is a video:" and one "Frame i sampled at t seconds:" line per frame. Per-frame and per-call pixel caps refuse a request instead of shrinking it. view_image returns an image file unchanged. - Dockerfile: OpenCode 1.17.11 and its plugin dependencies with the pins of visual_coding_opencode, the static FFmpeg 7.0.2 build pinned by SHA-256, Python 3.13 with NumPy 2.4.6, Pillow 12.3.0 and Pydantic 2.13.5. Tests cover the sampling, rounding, limits and text, the decode (seek against the sequential reference), the program's JSON replies, and the plugin under Node with a stand-in program. video_mcqa's environment gains NumPy and Pillow for these tests, and Gym's sandbox extra for the lending that follows. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * feat(video): agentic Video-MME v2, Video-MME and LVBench on stock opencode_agent Adds an agentic config to each of the three benchmarks. The stock opencode_agent runs each question through a single_agent_turn_legacy Environment Server, in a sandbox that the benchmark's resources server lends the episode, as visual_coding_opencode does. The sandbox image is video_mcqa/sandbox_image, and OpenCode loads its video tools plugin from there. video_mcqa/sandbox.py lends the sandbox for the video_mcqa and videomme_v2 servers (the videomme_v1 and lvbench servers inherit it). At each seed it: - refuses (422) a row whose video_binding.source is not a regular file under the configured video_roots; - starts the sandbox with the video tools' configuration (tools.json, from the server's video_tools settings) and two checksum lists; - uploads the video with nemo_gym.sandbox.upload_path; - runs one command in the sandbox: the image's video tools must have this repository's SHA-256 and the video the row's SHA-256 (422 otherwise), then the video becomes read-only and the tools check their configuration and FFmpeg. A command result with an error_type or the -1 sentinel, and any other failure, stops the sandbox and raises, so the Environment Server runs the episode again. The episode's close stops the sandbox. Grading never reads the sandbox. The verifiers read the stock agent's outcome: in the agentic setting a failed or incomplete response that reaches verify is an execution_failure scored 0, from the response's own status, so a replayed row scores the same. This replaces the video_execution_failure metadata key, which only the removed opencode_video_agent set. Single-turn scoring is unchanged. prepare.py names the video at --sandbox-root/sandbox_path (default /testbed) in agentic prompts. The three servers gain agentic example rows and cohorts, and their environments Gym's sandbox extra. READMEs describe the image, the tools, seeding, the single-upload size limit of the providers and the thinking switch. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * docs(video): agentic example rollouts with Nemotron 3 Nano Omni One rollout per agentic example row of the VideoMME-v2, VideoMME-v1 and LVBench servers, from nvidia/Nemotron-3-Nano-Omni-30B-A3B-Reasoning-BF16 on one GPU (vLLM 0.32.0rc1.dev190) through the stock opencode_agent, with OpenSandbox sandboxes from the video MCQA sandbox image. The shared README gives the serving flags, the commands and the outcomes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * fix(videomme_v2): let the questions of one group keep their own levels The Video-MME-v2 annotation gives every question its own level; the first three questions of a logic group can have a level other than the group's last question. The official scorer counts per-level accuracy by each question's own level and scores a group under the level of its last question. validate_metric_cohort no longer requires every task level to equal its group's level. When a cohort lists task_levels, each group's level must be the level of its last question, /L<n>/raw_acc counts questions by their task level, /L<n>/nonlinear_score counts groups by the group level, and the verifier checks a result's level against its task level, so rows that carry their own question level are scored instead of refused. A cohort without task_levels behaves as before: each question takes its group's level. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(video): let the sandbox tools read OpenCode's temporary files; drawtext, ripgrep and ImageMagick in the image - view_image and watch_video also read regular files under video_tools.scratch_roots, by default /tmp/opencode: OpenCode's bash tool keeps temporary files there, such as frames or contact sheets the model made, and the tools refused them. A relative path still starts at the workspace, a symlink that leads out of these directories is refused, and the text names such a file by its absolute path. The tool descriptions are unchanged. - The image's FFmpeg 7.0.2 is now the static build of mwader/static-ffmpeg, pinned by image digest and by the binaries' SHA-256. watch_video gets the same frames as with the previous 7.0.2 build (identical JPEG bytes on 50 requests over 7 videos); the new build also has libharfbuzz and fontconfig, so the model's drawtext works, with fontconfig and DejaVu for its default font. - ImageMagick for the model's montage and convert, with the URW fonts its labels default to, one thread (MAGICK_THREAD_LIMIT=1). - ripgrep stays (OpenCode's grep and glob run it offline). The build checks drawtext, ripgrep and montage. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * revert(video): the video tools and sandbox image before the scratch-file change This reverts commit cc13a8f: view_image and watch_video read files under the workspace only, not OpenCode's /tmp/opencode; the image's FFmpeg 7.0.2 is the johnvansickle.com static build again, without drawtext; and the image has no ImageMagick. The tree is again the one of 2f336e9. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * feat(openqa-rubric): open-ended video QA graded against each question's rubric A resources server for open-ended questions about a video, for RL training. The policy sees the video and the question; a judge model grades the final answer against the question's weighted-points rubric (criteria worth weight_points that add up to 100, and contradictions with a penalty and a score cap). The judge gets the question, the rubric and the final answer (no video, reasoning or reference answer) and returns a strict-JSON judgment; the server accepts it only when its points, applied contradictions and total add up, and the reward is the score / 100. The judge is any OpenAI-compatible chat model with JSON-schema structured output behind a judge ModelServerRef (judge_base_url, judge_api_key, judge_model_name), called through call_judge. A rejected judgment, a timeout and a 408/429/5xx reply are tried again up to judge_max_attempts; when every attempt fails, Gym's judge failsafe masks the row and keeps the answer for judge-only recovery. A failed model call is a masked infrastructure failure; a single-turn tool call or a failed agent run is an execution failure worth 0. empty_answer_reward (training only) sets the reward of an attempt that produced output but no final answer; an empty response stays 0, as Gym's agents require for execution_failure_reward_zero. Single-turn config (simple_agent, single_agent_turn_legacy) with five invented example rows on video_mcqa's synthetic clips, task_data schema, prepare_single_turn, README with the RL setup, tests with a scripted judge, and the component lock. video_mcqa's final_answer_text (the answer after any reasoning block) is now public so this server shares it. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(video): judge-read answers for the agentic configs <benchmark>_agentic_llm_extraction.yaml, listed after <benchmark>_agentic.yaml, gives the agentic resources server the judge model of llm_extraction_v1. The judge server listens on 127.0.0.1: the lent sandbox may reach every port of the policy model server's host and must not reach a judge. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(video): agentic rows with the benchmarks' own letter prompts prepare_agentic and prepare.py --prompt now write an agentic row in a benchmark's own letter wording: a first line that names the video in the sandbox (Video: /testbed/videos/<file>), then the single-turn letter prompt. Read its answers with llm_extraction_v1. The boxed prompt stays the default. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(openqa-rubric): example rollouts with Nemotron 3 Nano Omni One rollout per example row from nvidia/Nemotron-3-Nano-Omni-30B-A3B-Reasoning-BF16 on one GPU (vLLM 0.32.0rc1.dev190+g3f1bcfd82, the model card's video settings, default sampling), the same served model also judging for this example only. Three answers earn full points, one earns 60 of 100 (the direction but not the square), and on the counter the model runs out of output tokens (empty_answer, 0); the bar's first judgment was rejected by the arithmetic check and the second accepted. example_metrics.json from gym dataset collate (example_validation). The README records the commands. A failed judge attempt is now logged with its reason, never the answer. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(video): agentic Video-MME v2 and Video-MME benchmarks from the authors' annotations benchmarks/videomme_v2_agentic and benchmarks/videomme_v1_agentic run the agentic configs of the videomme_v2 and videomme_v1 resources servers with judge-read answers. prepare.py downloads the authors' annotation at a pinned revision and checks its SHA-256 (VIDEOMME_V2_PARQUET / VIDEOMME_V1_PARQUET name a local copy), then binds each question to its video by the SHA-256 that the source directory's FILES.sha256 lists, reading no video; the resources server checks that hash in the sandbox. Rows ask in the benchmark's letter wording after a line that names the video in the sandbox, and a judge model (gpt-6.1-sol at max reasoning effort by default) reads the chosen option. Video-MME v2 rows keep each question's own level and the cohort groups the four questions of each video under the level of the fourth, which the videomme_v2 server accepts with the per-question levels merged from NVIDIA-NeMo#6290. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(openqa-rubric): which video URLs and vLLM judges work The policy's model server reads the video URL: http(s) and data URLs, or a file:// URL the server may read (vLLM's --allowed-local-media-path). A vLLM-served judge works through the config's openai_model server, as in the example rollouts. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor(video-qa-rubric): rename openqa_rubric to video_qa_rubric The server grades open-ended questions about a video and builds on video_mcqa (its row types, final-answer reading and example clips), so its name now says so. Renamed: the folder resources_servers/ video_qa_rubric and configs/video_qa_rubric.yaml with the keys video_qa_rubric, video_qa_rubric_judge, video_qa_rubric_single_turn and video_qa_rubric_single_turn_environment; the VideoQARubric* classes; the project gym-resources-servers-video-qa-rubric (uv.lock differs only in that name); the failure kinds video_qa_rubric:*; the example task IDs video_qa_rubric:example-N; the rows in README.md and the environment list. The example rollouts carry the renamed task IDs, agent and environment names; the model's input and output, the judgments and the rewards are unchanged. What the judge receives is unchanged too: the system and user messages and the structured output's schema and its name. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(video-qa-rubric): import DatasetConfig from nemo_gym.config nemo_gym.config_types is the path from before 0.8.0; it still imports, with a deprecation warning, until 0.10.0. Server tests import public names from the package's public API, as scripts/migrate_imports.py writes them (its --check is now clean for this server). Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(video-qa-rubric): read failed agent runs from the response status, as video_mcqa does video_qa_rubric decided an agent run had failed from the video_execution_failure response metadata key, which only the removed opencode_video_agent set; this branch removed the key from video_mcqa, so video_qa_rubric could not even be imported here. It now uses video_mcqa's response_failure, like the Video-MME v2 server: in the agentic setting a failed or incomplete response that reaches verify is an execution_failure scored 0, read from the response's own status, so a replayed row scores the same. In the single-turn setting a failed model call stays a masked infrastructure_failure and a tool call an execution_failure; only the failure reasons now use video_mcqa's wording. The failed-run test covers failed and incomplete runs, and a new test checks that a failed model call is masked only in the single-turn setting. The README's outcome table says the same. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(video_mcqa): the judge reads each row's question; question sets, frame rows, empty-answer reward Make video_mcqa the shared base that the video multiple-choice benchmarks and other question sets fill with data and configuration. - Each row's verifier_metadata keeps the question as asked: question (its text) and options (the option texts in label order). VerifierMetadata and the task-data schemas require both, and prepare_single_turn, prepare_agentic and prepare.py write them. A row without them is refused: rows prepared before this change are prepared again, and nothing falls back to the request. - The llm_extraction_v1 judge builds its prompt from those two fields and the final answer only. It no longer reads the text of the model's request (scoring.prompt_text is gone), so the video, its frames and anything else in the prompt never reach it. videomme_v2 uses the same judge path. - A cohort may be a question set instead of a benchmark (question_set.py, QuestionSetCohort): two to 26 options, task IDs outside the benchmarks' scopes, no level or group, accuracy under the set's name. A training set runs on the shared verifier this way. The VideoMME-v1 and LVBench servers refuse such a cohort. - prepare_single_turn(..., frames=[(label, image_url), ...]) and task.video_parts send a video as labelled frames (input_image parts) instead of one input_video part. - empty_answer_reward (unset by default, which scores 0): the reward of an attempt that produced output but no final answer, for example a training penalty. Accuracy still counts the attempt as no_answer. - The shared rows take any number of options; VideoMME-v1 and LVBench check their four choices in their own task_data.py. - configs/video_mcqa_single_turn_llm_extraction.yaml: the shared verifier with the answer judge. The committed example rows and rollouts gain the two fields; nothing else in them changes. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(video): the agentic example rows keep each question's text and options NVIDIA-NeMo#6238 makes every video_mcqa row keep the question as asked (question, and options in label order) in verifier_metadata. The agentic Video-MME v2, Video-MME and LVBench examples gain the two fields, rebuilt with prepare_agentic from the same questions; nothing else in the rows or in the recorded rollouts changes. The benchmark wrappers write them through prepare_agentic. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(video-qa-rubric): agentic open-ended video questions with OpenCode and the video tools configs/video_qa_rubric_agentic.yaml runs video_qa_rubric's open-ended questions agentically, with the agent, sandbox image, video tools and sandbox settings of the agentic Video-MME v2, Video-MME and LVBench configs: the stock opencode_agent through a single_agent_turn_legacy Environment Server, a sandbox per episode that holds the row's video, and the rubric judge on 127.0.0.1 (the sandbox may reach every port of the policy model's host). - The resources server and its config take video_mcqa's VideoSandboxServer bases: with sandbox_provider set, each agentic episode's seed lends a sandbox with the row's video, checked by SHA-256; without it nothing changes. The sandbox extra joins the server's dependencies (uv.lock regenerated). - task.prepare_agentic(task_id, question, rubric, video_path=...) builds an agentic row's user turn (the question and the video's path in the sandbox, never the rubric); the row adds video_binding, which the task-data schema now declares. - data/example_agentic.jsonl: the five example questions and rubrics, each clip bound by path instead of inlined. - Tests: rows, bindings, the committed examples, the config against the agentic Video-MME v2 config, and the lent sandbox on the local provider. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * build(video-mcqa): sandbox image on the node:22 image the training data was generated in The agentic video training data was generated in the full node:22 Debian bookworm image (node@sha256:363e1587..., node 22.23.3) with the tools added at run time. The sandbox image now uses that image too, pinned by digest (the node:22.23.3-bookworm tag has been rebuilt since), so that evaluation and RL run in the same system: its shell, ImageMagick, git, compilers and other programs. The former final stage becomes the `tools` stage, unchanged apart from its base, which is now pinned by digest so that Python's files stay the same; the last stage copies its /usr/local (Python 3.13 with NumPy, Pillow and Pydantic, FFmpeg 7.0.2), /opt/opencode, /opt/video-mcqa and /usr/bin/rg into the node image as root-owned files, sets the same thread limits and locale, and makes /testbed and /testbed/work. The video tools, OpenCode and their pins are unchanged. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(video-mcqa): agentic OpenCode keeps its own tools and runs sh, as in the training data The agentic configs of videomme_v2, videomme_v1, lvbench and video_qa_rubric now run OpenCode's tools as the rollouts our agentic video training data came from did, so the model sees the same tools at evaluation and in RL: - No `tools` overrides: OpenCode offers its own tools, webfetch and task included, besides watch_video and view_image. webfetch fails in a sandbox that reaches only the model server, as it did then. OpenCode 1.17.11 offers websearch only with a search provider enabled, so it is not offered, as then. - The lent sandbox sets SHELL=/bin/sh (`sandbox_config.env`). OpenCode's shell tool runs commands with the shell SHELL names, bash when it is unset, and names that shell in the tool's description ("Shell: sh"). With these configs, the tools in the first request of an OpenCode 1.17.11 run in the sandbox image have the names, descriptions and parameters of the tool block of the training trajectories. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(video-mcqa): agentic OpenCode ends a run on a third identical tool call, as in the training data The agentic configs of videomme_v2, videomme_v1, lvbench and video_qa_rubric set OpenCode's doom_loop permission to ask, OpenCode's default and the setting of the rollouts our agentic video training data came from, instead of allow. OpenCode 1.17.11 asks for doom_loop when the last three parts of one model response are calls of the same tool with identical input. `opencode run` rejects every request that would ask, and this rejection ends the run without an answer, as it did when the training data was generated. With allow, the third call ran and the model went on. The same call repeated across separate responses does not reach that check, with either setting. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * fix(video-mcqa): the sandbox tools read OpenCode's temporary files; drawtext, montage and annotate work in the image - view_image and watch_video also read regular files under video_tools.scratch_roots, by default /tmp/opencode: OpenCode's bash tool keeps temporary files there, such as frames or contact sheets the model made, and the tools refused them. A relative path still starts at the workspace, a symlink that leads out of these directories is refused, and the text names such a file by its absolute path. The tool descriptions are unchanged. - FFmpeg 7.0.2 is now the static build of mwader/static-ffmpeg, pinned by image digest and by the binaries' SHA-256. watch_video gets the same frames as with the johnvansickle.com 7.0.2 build (identical JPEG bytes on 50 requests); the new build also has libharfbuzz and fontconfig, so the model's drawtext works, with the image's DejaVu font. - The image gets the URW fonts that ImageMagick's labels and annotations default to (Helvetica). Without them, montage and convert -annotate abort in the node:22 image. - The build checks drawtext, ripgrep, montage with a label and convert -annotate. The tool code is that of cc13a8f, which c44e06a reverted; the node:22 image already has ImageMagick, fontconfig and DejaVu. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * fix(video-mcqa): agentic OpenCode no longer offers webfetch The agentic configs of videomme_v2, videomme_v1, lvbench and video_qa_rubric turn off OpenCode's webfetch tool (`tools: {webfetch: false}`), so the model is not offered it. The lent sandbox reaches only the policy model server, so every webfetch call failed with a transport error, as in the rollouts our agentic video training data came from. The other tools stay as in that training data: bash (on sh), edit, glob, grep, read, skill, task, todowrite and write, with watch_video and view_image. doom_loop stays at ask and compaction off. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * feat(video-mcqa): watch_video's text for frames attached after the tool results For an OpenAI-compatible provider, OpenCode sends the images of all the tool results of one response after those results, in one user message ("Attached media from tool result:"), in call order. watch_video's text was written for images placed right after their labels: "This is a video:" and one "Frame i sampled at t seconds:" line per frame, each ending in a colon that the model sees nothing after. watch_video's text now says what was sampled (the frame count, the number of distinct frames when the video holds some, the video, the window, the spacing, the frame size and the visual tokens), that the frames are attached after the tool results in this order, and each frame's sampling time: Sampled 42 frames of videos/a.mp4 from 120.00 s to 240.00 s, one every 2.86 s, at 616×336 (11088 visual tokens). The 42 frames are attached after the tool results, in this order: Frame 1: 121.43 s Frame 2: 124.29 s ... The lines about source PTS and the largest gap between distinct source frames are dropped. watch_video's description adds that the images of several tool calls in one response follow in call order. The frame rules and the frames are unchanged; view_image is unchanged. The text and the description come from the image's video tools, so the sandbox image needs a rebuild: the seed check refuses an image whose tools differ. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * fix(video-mcqa): saved rule-scored results without the question; a non-string judge choice Aggregating results saved before rows carried the question and its options raised TypeError: VerifierMetadata required both. They are optional again, given together or not at all. The rule policies and aggregation never read them, so such boxed_only_v1 results aggregate and replay as before. Under llm_extraction_v1 the judge reads them, so that policy refuses a row without them before any judge call. A judge reply {"choice": null} was read as the string "None" and scored as no_choice, a measured zero. A choice that is not a string is now an unusable reply: Gym's judge failsafe masks the row for rejudging. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * fix(video-qa-rubric): grade the last assistant message; empty_answer_reward only rewards no answer With empty_answer_reward set, the answer also had to be the last thing the model produced, and that rule missed a response ending on reasoning after the answer: [answer, reasoning] graded the answer instead of giving the configured reward. The rule is gone: the final answer is always the text of the last assistant message after its reasoning, whatever comes after it, as in video_mcqa. empty_answer_reward stays, as video_mcqa's option: the reward of an attempt that produced output but no final answer. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * feat(video-mcqa): cap the tool images an episode sends by count too Every request sends the episode's earlier tool images again. The plugin capped them by max_tool_media_bytes (400 MiB of base64) only, so small frames could pass that and still exceed the model server's image limit per request: two watch_video results of 150 small frames make a request with 300 images, over the 256 that the README's vLLM example allowed. max_tool_media_images (ToolSettings, default 8192) caps their number the same way: from the tool result whose images would pass either limit on, each result shows the notice in place of its images, the same in every request, and earlier results keep theirs. The README's vLLM example now takes 8192 images per request, and the README says to change the two together. The plugin and video_tools/contract.py are files of the sandbox image, so the image needs a rebuild: the seed check refuses an image whose tools differ. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * fix(video-mcqa): read a relative cohort_manifest from the Gym root The agentic Video-MME benchmarks (benchmarks/videomme_v1_agentic, benchmarks/videomme_v2_agentic) default the cohort manifest to their prepared file, benchmarks/<name>/data/<name>_cohort.json, a path from the Gym root. Gym starts each resources server in its own directory, and the servers read the path as given, so a run with the benchmarks' default stopped at server start with FileNotFoundError. Runs that passed an absolute path were not affected. The video_mcqa server (videomme_v1, lvbench, question sets) and the videomme_v2 server now resolve the path with _resolve_under_cwd_or_install, as tavily_search and hle_web_tools resolve their files: an absolute path is used as given, and a relative one is looked up under NEMO_GYM_EXTRA_ROOTS, the working directory, then the Gym root. The sandbox image's files do not change, so an image built from the previous commit still passes the seed check. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * build(video-qa-rubric): refresh component lock against main Signed-off-by: yaoyu-33 <[email protected]> * build(video-mcqa): refresh the video servers' component locks against main Relocked with uv 0.13.4 on top of main's upgraded locks (NVIDIA-NeMo#6528): lvbench, video_mcqa, videomme_v1, videomme_v2 and video_qa_rubric. Each lock only gains the packages of this branch's dependencies (nemo-gym's sandbox extra, and pillow 12.3.0 in video_mcqa); python-dateutil is 2.9.0.post0 again, as in main's other locks with the sandbox extra. Signed-off-by: Guo Chen <[email protected]> * test(video-mcqa): pass the stop limit through the fixture that counts stops main's NVIDIA-NeMo#6410 gives AsyncSandbox.stop a timeout_s keyword, and lending now passes it. The `stopped` fixture (also used by video_qa_rubric's agentic tests) wraps the real stop, so it takes and forwards the keyword, as main's other session tests do since NVIDIA-NeMo#6410. Signed-off-by: Guo Chen <[email protected]> * test(video-mcqa): run the agentic Video-MME prepare tests with the video_mcqa server tests The tests import both benchmarks' prepare.py and, through them, the video_mcqa and videomme_v2 server modules, so in the core suite they added those modules to the core coverage measurement. The video_mcqa server tests, which cover those modules, now run them. The tests are unchanged. Signed-off-by: Guo Chen <[email protected]> --------- Signed-off-by: Guo Chen <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: yaoyu-33 <[email protected]>
ehosseiniasl
pushed a commit
to ehosseiniasl/Gym
that referenced
this pull request
Nov 21, 2026
…swer level grading and video media preloaded in the sandbox image (NVIDIA-NeMo#6460) * refactor(video): import nemo_gym names from their public packages The four video servers and their tests imported the pre-0.8 module paths (nemo_gym.base_resources_server, config_types, global_config, openai_utils, server_utils), which still import with a deprecation warning. They now import each name from its package's public API, as scripts/migrate_imports.py writes it; `migrate_imports.py --check` reports nothing for these folders. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * feat(video): optional judge-model answer extraction for Video-MME v2, Video-MME and LVBench Add answer_policy llm_extraction_v1 to the shared video MCQA scoring. A judge model (any OpenAI-compatible chat model behind a Gym model server, called through call_judge on /v1/chat/completions) reads which option a final answer gives; the verifier scores that option against the gold label. The judge sees the prompt's text (no media) and the final answer (no reasoning), never the gold label. - A "none" reading is the new outcome no_choice (a measured zero); an empty final answer stays no_answer and is not sent. - A failed judge call or a reply that names no option raises a judge failure: Gym's judge failsafe masks the row and keeps it with its answer in the failures file, so the frozen cohort counts the task as missing until it is judged again. - The judged grading, verify response included, runs in observe_llm_judge_grading, so Gym binds the graded response and reward to the judge's reply. - The cohort declares the policy; a server whose cohort uses it refuses to start without judge_model_server. The rule policies stay the default and never call a judge. - prepare_single_turn and prepare.py take a prompt style: boxed (default) or the benchmark's bare-letter prompt (videomme_v2, videomme_v1, lvbench). - New configs <benchmark>_single_turn_llm_extraction.yaml for the three benchmarks: the single-turn config plus an openai_model judge (judge_base_url, judge_api_key, judge_model_name). Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(video): sandbox image with frame-sampling video tools for OpenCode Adds resources_servers/video_mcqa/sandbox_image: a Dockerfile and the video tools it installs in /opt/video-mcqa. - video_tools.mjs: an OpenCode 1.17.11 plugin with watch_video and view_image. It runs `python3 -I -m video_tools.cli` once per call and returns the images as tool attachments. It also caps the tool images that one episode sends (400 MiB of base64 by default): from the result that would pass the cap on, results show a notice in place of their images, the same in every request. The tools take plain JSON Schema arguments, so the plugin imports only Node's standard library. - video_tools: watch_video samples the center of each of num_frames equal bins of [start, end), takes the latest source frame not after each sampling time, resizes by area to the requested long edge rounded down to the model's grid (patch_size / downsample_ratio, 28 px by default) and returns JPEG frames (quality 95, 4:4:4) with "This is a video:" and one "Frame i sampled at t seconds:" line per frame. Per-frame and per-call pixel caps refuse a request instead of shrinking it. view_image returns an image file unchanged. - Dockerfile: OpenCode 1.17.11 and its plugin dependencies with the pins of visual_coding_opencode, the static FFmpeg 7.0.2 build pinned by SHA-256, Python 3.13 with NumPy 2.4.6, Pillow 12.3.0 and Pydantic 2.13.5. Tests cover the sampling, rounding, limits and text, the decode (seek against the sequential reference), the program's JSON replies, and the plugin under Node with a stand-in program. video_mcqa's environment gains NumPy and Pillow for these tests, and Gym's sandbox extra for the lending that follows. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * feat(video): agentic Video-MME v2, Video-MME and LVBench on stock opencode_agent Adds an agentic config to each of the three benchmarks. The stock opencode_agent runs each question through a single_agent_turn_legacy Environment Server, in a sandbox that the benchmark's resources server lends the episode, as visual_coding_opencode does. The sandbox image is video_mcqa/sandbox_image, and OpenCode loads its video tools plugin from there. video_mcqa/sandbox.py lends the sandbox for the video_mcqa and videomme_v2 servers (the videomme_v1 and lvbench servers inherit it). At each seed it: - refuses (422) a row whose video_binding.source is not a regular file under the configured video_roots; - starts the sandbox with the video tools' configuration (tools.json, from the server's video_tools settings) and two checksum lists; - uploads the video with nemo_gym.sandbox.upload_path; - runs one command in the sandbox: the image's video tools must have this repository's SHA-256 and the video the row's SHA-256 (422 otherwise), then the video becomes read-only and the tools check their configuration and FFmpeg. A command result with an error_type or the -1 sentinel, and any other failure, stops the sandbox and raises, so the Environment Server runs the episode again. The episode's close stops the sandbox. Grading never reads the sandbox. The verifiers read the stock agent's outcome: in the agentic setting a failed or incomplete response that reaches verify is an execution_failure scored 0, from the response's own status, so a replayed row scores the same. This replaces the video_execution_failure metadata key, which only the removed opencode_video_agent set. Single-turn scoring is unchanged. prepare.py names the video at --sandbox-root/sandbox_path (default /testbed) in agentic prompts. The three servers gain agentic example rows and cohorts, and their environments Gym's sandbox extra. READMEs describe the image, the tools, seeding, the single-upload size limit of the providers and the thinking switch. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * docs(video): agentic example rollouts with Nemotron 3 Nano Omni One rollout per agentic example row of the VideoMME-v2, VideoMME-v1 and LVBench servers, from nvidia/Nemotron-3-Nano-Omni-30B-A3B-Reasoning-BF16 on one GPU (vLLM 0.32.0rc1.dev190) through the stock opencode_agent, with OpenSandbox sandboxes from the video MCQA sandbox image. The shared README gives the serving flags, the commands and the outcomes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * fix(videomme_v2): let the questions of one group keep their own levels The Video-MME-v2 annotation gives every question its own level; the first three questions of a logic group can have a level other than the group's last question. The official scorer counts per-level accuracy by each question's own level and scores a group under the level of its last question. validate_metric_cohort no longer requires every task level to equal its group's level. When a cohort lists task_levels, each group's level must be the level of its last question, /L<n>/raw_acc counts questions by their task level, /L<n>/nonlinear_score counts groups by the group level, and the verifier checks a result's level against its task level, so rows that carry their own question level are scored instead of refused. A cohort without task_levels behaves as before: each question takes its group's level. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(video): let the sandbox tools read OpenCode's temporary files; drawtext, ripgrep and ImageMagick in the image - view_image and watch_video also read regular files under video_tools.scratch_roots, by default /tmp/opencode: OpenCode's bash tool keeps temporary files there, such as frames or contact sheets the model made, and the tools refused them. A relative path still starts at the workspace, a symlink that leads out of these directories is refused, and the text names such a file by its absolute path. The tool descriptions are unchanged. - The image's FFmpeg 7.0.2 is now the static build of mwader/static-ffmpeg, pinned by image digest and by the binaries' SHA-256. watch_video gets the same frames as with the previous 7.0.2 build (identical JPEG bytes on 50 requests over 7 videos); the new build also has libharfbuzz and fontconfig, so the model's drawtext works, with fontconfig and DejaVu for its default font. - ImageMagick for the model's montage and convert, with the URW fonts its labels default to, one thread (MAGICK_THREAD_LIMIT=1). - ripgrep stays (OpenCode's grep and glob run it offline). The build checks drawtext, ripgrep and montage. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * revert(video): the video tools and sandbox image before the scratch-file change This reverts commit cc13a8f: view_image and watch_video read files under the workspace only, not OpenCode's /tmp/opencode; the image's FFmpeg 7.0.2 is the johnvansickle.com static build again, without drawtext; and the image has no ImageMagick. The tree is again the one of 2f336e9. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * feat(openqa-rubric): open-ended video QA graded against each question's rubric A resources server for open-ended questions about a video, for RL training. The policy sees the video and the question; a judge model grades the final answer against the question's weighted-points rubric (criteria worth weight_points that add up to 100, and contradictions with a penalty and a score cap). The judge gets the question, the rubric and the final answer (no video, reasoning or reference answer) and returns a strict-JSON judgment; the server accepts it only when its points, applied contradictions and total add up, and the reward is the score / 100. The judge is any OpenAI-compatible chat model with JSON-schema structured output behind a judge ModelServerRef (judge_base_url, judge_api_key, judge_model_name), called through call_judge. A rejected judgment, a timeout and a 408/429/5xx reply are tried again up to judge_max_attempts; when every attempt fails, Gym's judge failsafe masks the row and keeps the answer for judge-only recovery. A failed model call is a masked infrastructure failure; a single-turn tool call or a failed agent run is an execution failure worth 0. empty_answer_reward (training only) sets the reward of an attempt that produced output but no final answer; an empty response stays 0, as Gym's agents require for execution_failure_reward_zero. Single-turn config (simple_agent, single_agent_turn_legacy) with five invented example rows on video_mcqa's synthetic clips, task_data schema, prepare_single_turn, README with the RL setup, tests with a scripted judge, and the component lock. video_mcqa's final_answer_text (the answer after any reasoning block) is now public so this server shares it. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(video): judge-read answers for the agentic configs <benchmark>_agentic_llm_extraction.yaml, listed after <benchmark>_agentic.yaml, gives the agentic resources server the judge model of llm_extraction_v1. The judge server listens on 127.0.0.1: the lent sandbox may reach every port of the policy model server's host and must not reach a judge. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(video): agentic rows with the benchmarks' own letter prompts prepare_agentic and prepare.py --prompt now write an agentic row in a benchmark's own letter wording: a first line that names the video in the sandbox (Video: /testbed/videos/<file>), then the single-turn letter prompt. Read its answers with llm_extraction_v1. The boxed prompt stays the default. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(openqa-rubric): example rollouts with Nemotron 3 Nano Omni One rollout per example row from nvidia/Nemotron-3-Nano-Omni-30B-A3B-Reasoning-BF16 on one GPU (vLLM 0.32.0rc1.dev190+g3f1bcfd82, the model card's video settings, default sampling), the same served model also judging for this example only. Three answers earn full points, one earns 60 of 100 (the direction but not the square), and on the counter the model runs out of output tokens (empty_answer, 0); the bar's first judgment was rejected by the arithmetic check and the second accepted. example_metrics.json from gym dataset collate (example_validation). The README records the commands. A failed judge attempt is now logged with its reason, never the answer. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(video): agentic Video-MME v2 and Video-MME benchmarks from the authors' annotations benchmarks/videomme_v2_agentic and benchmarks/videomme_v1_agentic run the agentic configs of the videomme_v2 and videomme_v1 resources servers with judge-read answers. prepare.py downloads the authors' annotation at a pinned revision and checks its SHA-256 (VIDEOMME_V2_PARQUET / VIDEOMME_V1_PARQUET name a local copy), then binds each question to its video by the SHA-256 that the source directory's FILES.sha256 lists, reading no video; the resources server checks that hash in the sandbox. Rows ask in the benchmark's letter wording after a line that names the video in the sandbox, and a judge model (gpt-6.1-sol at max reasoning effort by default) reads the chosen option. Video-MME v2 rows keep each question's own level and the cohort groups the four questions of each video under the level of the fourth, which the videomme_v2 server accepts with the per-question levels merged from NVIDIA-NeMo#6290. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(openqa-rubric): which video URLs and vLLM judges work The policy's model server reads the video URL: http(s) and data URLs, or a file:// URL the server may read (vLLM's --allowed-local-media-path). A vLLM-served judge works through the config's openai_model server, as in the example rollouts. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor(video-qa-rubric): rename openqa_rubric to video_qa_rubric The server grades open-ended questions about a video and builds on video_mcqa (its row types, final-answer reading and example clips), so its name now says so. Renamed: the folder resources_servers/ video_qa_rubric and configs/video_qa_rubric.yaml with the keys video_qa_rubric, video_qa_rubric_judge, video_qa_rubric_single_turn and video_qa_rubric_single_turn_environment; the VideoQARubric* classes; the project gym-resources-servers-video-qa-rubric (uv.lock differs only in that name); the failure kinds video_qa_rubric:*; the example task IDs video_qa_rubric:example-N; the rows in README.md and the environment list. The example rollouts carry the renamed task IDs, agent and environment names; the model's input and output, the judgments and the rewards are unchanged. What the judge receives is unchanged too: the system and user messages and the structured output's schema and its name. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(video-qa-rubric): import DatasetConfig from nemo_gym.config nemo_gym.config_types is the path from before 0.8.0; it still imports, with a deprecation warning, until 0.10.0. Server tests import public names from the package's public API, as scripts/migrate_imports.py writes them (its --check is now clean for this server). Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(video-qa-rubric): read failed agent runs from the response status, as video_mcqa does video_qa_rubric decided an agent run had failed from the video_execution_failure response metadata key, which only the removed opencode_video_agent set; this branch removed the key from video_mcqa, so video_qa_rubric could not even be imported here. It now uses video_mcqa's response_failure, like the Video-MME v2 server: in the agentic setting a failed or incomplete response that reaches verify is an execution_failure scored 0, read from the response's own status, so a replayed row scores the same. In the single-turn setting a failed model call stays a masked infrastructure_failure and a tool call an execution_failure; only the failure reasons now use video_mcqa's wording. The failed-run test covers failed and incomplete runs, and a new test checks that a failed model call is masked only in the single-turn setting. The README's outcome table says the same. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(video_mcqa): the judge reads each row's question; question sets, frame rows, empty-answer reward Make video_mcqa the shared base that the video multiple-choice benchmarks and other question sets fill with data and configuration. - Each row's verifier_metadata keeps the question as asked: question (its text) and options (the option texts in label order). VerifierMetadata and the task-data schemas require both, and prepare_single_turn, prepare_agentic and prepare.py write them. A row without them is refused: rows prepared before this change are prepared again, and nothing falls back to the request. - The llm_extraction_v1 judge builds its prompt from those two fields and the final answer only. It no longer reads the text of the model's request (scoring.prompt_text is gone), so the video, its frames and anything else in the prompt never reach it. videomme_v2 uses the same judge path. - A cohort may be a question set instead of a benchmark (question_set.py, QuestionSetCohort): two to 26 options, task IDs outside the benchmarks' scopes, no level or group, accuracy under the set's name. A training set runs on the shared verifier this way. The VideoMME-v1 and LVBench servers refuse such a cohort. - prepare_single_turn(..., frames=[(label, image_url), ...]) and task.video_parts send a video as labelled frames (input_image parts) instead of one input_video part. - empty_answer_reward (unset by default, which scores 0): the reward of an attempt that produced output but no final answer, for example a training penalty. Accuracy still counts the attempt as no_answer. - The shared rows take any number of options; VideoMME-v1 and LVBench check their four choices in their own task_data.py. - configs/video_mcqa_single_turn_llm_extraction.yaml: the shared verifier with the answer judge. The committed example rows and rollouts gain the two fields; nothing else in them changes. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(video): the agentic example rows keep each question's text and options NVIDIA-NeMo#6238 makes every video_mcqa row keep the question as asked (question, and options in label order) in verifier_metadata. The agentic Video-MME v2, Video-MME and LVBench examples gain the two fields, rebuilt with prepare_agentic from the same questions; nothing else in the rows or in the recorded rollouts changes. The benchmark wrappers write them through prepare_agentic. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(video-qa-rubric): agentic open-ended video questions with OpenCode and the video tools configs/video_qa_rubric_agentic.yaml runs video_qa_rubric's open-ended questions agentically, with the agent, sandbox image, video tools and sandbox settings of the agentic Video-MME v2, Video-MME and LVBench configs: the stock opencode_agent through a single_agent_turn_legacy Environment Server, a sandbox per episode that holds the row's video, and the rubric judge on 127.0.0.1 (the sandbox may reach every port of the policy model's host). - The resources server and its config take video_mcqa's VideoSandboxServer bases: with sandbox_provider set, each agentic episode's seed lends a sandbox with the row's video, checked by SHA-256; without it nothing changes. The sandbox extra joins the server's dependencies (uv.lock regenerated). - task.prepare_agentic(task_id, question, rubric, video_path=...) builds an agentic row's user turn (the question and the video's path in the sandbox, never the rubric); the row adds video_binding, which the task-data schema now declares. - data/example_agentic.jsonl: the five example questions and rubrics, each clip bound by path instead of inlined. - Tests: rows, bindings, the committed examples, the config against the agentic Video-MME v2 config, and the lent sandbox on the local provider. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * build(video-mcqa): sandbox image on the node:22 image the training data was generated in The agentic video training data was generated in the full node:22 Debian bookworm image (node@sha256:363e1587..., node 22.23.3) with the tools added at run time. The sandbox image now uses that image too, pinned by digest (the node:22.23.3-bookworm tag has been rebuilt since), so that evaluation and RL run in the same system: its shell, ImageMagick, git, compilers and other programs. The former final stage becomes the `tools` stage, unchanged apart from its base, which is now pinned by digest so that Python's files stay the same; the last stage copies its /usr/local (Python 3.13 with NumPy, Pillow and Pydantic, FFmpeg 7.0.2), /opt/opencode, /opt/video-mcqa and /usr/bin/rg into the node image as root-owned files, sets the same thread limits and locale, and makes /testbed and /testbed/work. The video tools, OpenCode and their pins are unchanged. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(video-mcqa): agentic OpenCode keeps its own tools and runs sh, as in the training data The agentic configs of videomme_v2, videomme_v1, lvbench and video_qa_rubric now run OpenCode's tools as the rollouts our agentic video training data came from did, so the model sees the same tools at evaluation and in RL: - No `tools` overrides: OpenCode offers its own tools, webfetch and task included, besides watch_video and view_image. webfetch fails in a sandbox that reaches only the model server, as it did then. OpenCode 1.17.11 offers websearch only with a search provider enabled, so it is not offered, as then. - The lent sandbox sets SHELL=/bin/sh (`sandbox_config.env`). OpenCode's shell tool runs commands with the shell SHELL names, bash when it is unset, and names that shell in the tool's description ("Shell: sh"). With these configs, the tools in the first request of an OpenCode 1.17.11 run in the sandbox image have the names, descriptions and parameters of the tool block of the training trajectories. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(video-mcqa): agentic OpenCode ends a run on a third identical tool call, as in the training data The agentic configs of videomme_v2, videomme_v1, lvbench and video_qa_rubric set OpenCode's doom_loop permission to ask, OpenCode's default and the setting of the rollouts our agentic video training data came from, instead of allow. OpenCode 1.17.11 asks for doom_loop when the last three parts of one model response are calls of the same tool with identical input. `opencode run` rejects every request that would ask, and this rejection ends the run without an answer, as it did when the training data was generated. With allow, the third call ran and the model went on. The same call repeated across separate responses does not reach that check, with either setting. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * fix(video-mcqa): the sandbox tools read OpenCode's temporary files; drawtext, montage and annotate work in the image - view_image and watch_video also read regular files under video_tools.scratch_roots, by default /tmp/opencode: OpenCode's bash tool keeps temporary files there, such as frames or contact sheets the model made, and the tools refused them. A relative path still starts at the workspace, a symlink that leads out of these directories is refused, and the text names such a file by its absolute path. The tool descriptions are unchanged. - FFmpeg 7.0.2 is now the static build of mwader/static-ffmpeg, pinned by image digest and by the binaries' SHA-256. watch_video gets the same frames as with the johnvansickle.com 7.0.2 build (identical JPEG bytes on 50 requests); the new build also has libharfbuzz and fontconfig, so the model's drawtext works, with the image's DejaVu font. - The image gets the URW fonts that ImageMagick's labels and annotations default to (Helvetica). Without them, montage and convert -annotate abort in the node:22 image. - The build checks drawtext, ripgrep, montage with a label and convert -annotate. The tool code is that of cc13a8f, which c44e06a reverted; the node:22 image already has ImageMagick, fontconfig and DejaVu. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * fix(video-mcqa): agentic OpenCode no longer offers webfetch The agentic configs of videomme_v2, videomme_v1, lvbench and video_qa_rubric turn off OpenCode's webfetch tool (`tools: {webfetch: false}`), so the model is not offered it. The lent sandbox reaches only the policy model server, so every webfetch call failed with a transport error, as in the rollouts our agentic video training data came from. The other tools stay as in that training data: bash (on sh), edit, glob, grep, read, skill, task, todowrite and write, with watch_video and view_image. doom_loop stays at ask and compaction off. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * feat(video-qa-rubric): reference-answer level grading, per-subset scores, and video media preloaded in the sandbox image video_qa_rubric: each row's verifier_metadata.grading names its protocol. Rows without it keep the weighted-points rubric, its request model and its checks unchanged. A reference_levels row carries a reference answer and a rubric of any JSON object; the judge reads them with the question and the final answer through the server's reference_levels settings (a question set's own system prompt and user template, and its top level) and must reply with exactly {"score", "reason"}; the reward is the level over the top level. A server without these settings refuses such rows. Rows that name a subset also get each subset's mean rubric score and the mean over the subsets in the metrics. The row builders take the text after the video, the protocol, the reference answer and the subset, and an agentic row's whole text for videos the image already holds. video_mcqa: an agentic row can name media that its sandbox image already holds (preloaded_media: the image's name in the server's sandbox_preloaded_images, the image's catalog and its SHA-256, and host files to copy in). The seed starts the sandbox from that image, uploads nothing, and checks in the sandbox the video tools, the catalog's SHA-256 and the size of every file it lists, moves the catalog out of the model's media root and makes the copied files read-only. Each image lends its own sandboxes; rows with an uploaded video are unchanged. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(benchmarks): MM-Lifelong v1.1 single-turn and agentic as video_qa_rubric question sets mm_lifelong_v1_1: the 1,023 questions of day_test, week_test and month_val with frozen rubrics. prepare.py reads the annotations at a pinned revision of the Hugging Face dataset (downloading what is missing) and checks them against the release's checksums, whose own SHA-256 is pinned; the model sees each split as one MP4 of 256 frames at the centres of equal bins, taken from the release's frame cache that the user downloads (each shard read is checked), with the question as it is. grading.yaml is the dataset's grader on video_qa_rubric's reference_levels protocol: its prompt and template, the reference answer, 0-5 levels, one completion; each split is a subset, so the metrics give the split scores and their mean. mm_lifelong_v1_1_agentic: the same questions answered by OpenCode with the video tools in a sandbox whose image holds the split's original videos (preloaded media). The videos are not redistributed: sandbox_image/build.py checks the user's copy against the sizes and SHA-256 the Hub keeps, writes the image's catalog and the dataset runner's catalog that the model reads, and builds one image per split on the video tools' image. Rows ask with the runner's description of the inputs and its time-coordinates note. The grader prompt and the runner's note are MIT-licensed text of the dataset; the notice is in third-party-notices.md and ATTRIBUTIONS.md. Signed-off-by: Guo Chen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(video-mcqa): watch_video's text for frames attached after the tool results For an OpenAI-compatible provider, OpenCode sends the images of all the tool results of one response after those results, in one user message ("Attached media from tool result:"), in call order. watch_video's text was written for images placed right after their labels: "This is a video:" and one "Frame i sampled at t seconds:" line per frame, each ending in a colon that the model sees nothing after. watch_video's text now says what was sampled (the frame count, the number of distinct frames when the video holds some, the video, the window, the spacing, the frame size and the visual tokens), that the frames are attached after the tool results in this order, and each frame's sampling time: Sampled 42 frames of videos/a.mp4 from 120.00 s to 240.00 s, one every 2.86 s, at 616×336 (11088 visual tokens). The 42 frames are attached after the tool results, in this order: Frame 1: 121.43 s Frame 2: 124.29 s ... The lines about source PTS and the largest gap between distinct source frames are dropped. watch_video's description adds that the images of several tool calls in one response follow in call order. The frame rules and the frames are unchanged; view_image is unchanged. The text and the description come from the image's video tools, so the sandbox image needs a rebuild: the seed check refuses an image whose tools differ. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * fix(video-mcqa): saved rule-scored results without the question; a non-string judge choice Aggregating results saved before rows carried the question and its options raised TypeError: VerifierMetadata required both. They are optional again, given together or not at all. The rule policies and aggregation never read them, so such boxed_only_v1 results aggregate and replay as before. Under llm_extraction_v1 the judge reads them, so that policy refuses a row without them before any judge call. A judge reply {"choice": null} was read as the string "None" and scored as no_choice, a measured zero. A choice that is not a string is now an unusable reply: Gym's judge failsafe masks the row for rejudging. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * fix(video-qa-rubric): grade the last assistant message; empty_answer_reward only rewards no answer With empty_answer_reward set, the answer also had to be the last thing the model produced, and that rule missed a response ending on reasoning after the answer: [answer, reasoning] graded the answer instead of giving the configured reward. The rule is gone: the final answer is always the text of the last assistant message after its reasoning, whatever comes after it, as in video_mcqa. empty_answer_reward stays, as video_mcqa's option: the reward of an attempt that produced output but no final answer. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * feat(video-mcqa): cap the tool images an episode sends by count too Every request sends the episode's earlier tool images again. The plugin capped them by max_tool_media_bytes (400 MiB of base64) only, so small frames could pass that and still exceed the model server's image limit per request: two watch_video results of 150 small frames make a request with 300 images, over the 256 that the README's vLLM example allowed. max_tool_media_images (ToolSettings, default 8192) caps their number the same way: from the tool result whose images would pass either limit on, each result shows the notice in place of its images, the same in every request, and earlier results keep theirs. The README's vLLM example now takes 8192 images per request, and the README says to change the two together. The plugin and video_tools/contract.py are files of the sandbox image, so the image needs a rebuild: the seed check refuses an image whose tools differ. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * fix(mm-lifelong-v1-1): the image gets only the release's videos; overall score wording build.py built the image from the local videos/<domain>/ folder itself, so each week day folder went in whole, with any local file that the verified catalog does not list (a partial download, notes). The build now reads a temporary folder in the output directory that holds only the catalog's files, as hard links to the local copy (copies when the output directory is on another file system), with the source folders' times. The script lists the other local files and leaves them out. Without such files the image is the same as before: from invented week and month videos, the old and the new script give the same layers on one builder, and on fresh builds the same entries apart from the parent folders' build times, which also differ between two fresh builds of the old script. mm_lifelong_v1_1/config.yaml said the dataset's overall score is the mean of the split scores. It pools all 1,023 questions (mean/rubric_score); the mean of the three split scores is a separate metric. Comment only. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * fix(video-mcqa): read a relative cohort_manifest from the Gym root The agentic Video-MME benchmarks (benchmarks/videomme_v1_agentic, benchmarks/videomme_v2_agentic) default the cohort manifest to their prepared file, benchmarks/<name>/data/<name>_cohort.json, a path from the Gym root. Gym starts each resources server in its own directory, and the servers read the path as given, so a run with the benchmarks' default stopped at server start with FileNotFoundError. Runs that passed an absolute path were not affected. The video_mcqa server (videomme_v1, lvbench, question sets) and the videomme_v2 server now resolve the path with _resolve_under_cwd_or_install, as tavily_search and hle_web_tools resolve their files: an absolute path is used as given, and a relative one is looked up under NEMO_GYM_EXTRA_ROOTS, the working directory, then the Gym root. The sandbox image's files do not change, so an image built from the previous commit still passes the seed check. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Guo Chen <[email protected]> * build(video-qa-rubric): refresh component lock against main Signed-off-by: yaoyu-33 <[email protected]> * build(video-mcqa): refresh the video servers' component locks against main Relocked with uv 0.13.4 on top of main's upgraded locks (NVIDIA-NeMo#6528): lvbench, video_mcqa, videomme_v1, videomme_v2 and video_qa_rubric. Each lock only gains the packages of this branch's dependencies (nemo-gym's sandbox extra, and pillow 12.3.0 in video_mcqa); python-dateutil is 2.9.0.post0 again, as in main's other locks with the sandbox extra. Signed-off-by: Guo Chen <[email protected]> * test(video-mcqa): pass the stop limit through the fixture that counts stops main's NVIDIA-NeMo#6410 gives AsyncSandbox.stop a timeout_s keyword, and lending now passes it. The `stopped` fixture (also used by video_qa_rubric's agentic tests) wraps the real stop, so it takes and forwards the keyword, as main's other session tests do since NVIDIA-NeMo#6410. Signed-off-by: Guo Chen <[email protected]> * test(video-mcqa): run the agentic Video-MME prepare tests with the video_mcqa server tests The tests import both benchmarks' prepare.py and, through them, the video_mcqa and videomme_v2 server modules, so in the core suite they added those modules to the core coverage measurement. The video_mcqa server tests, which cover those modules, now run them. The tests are unchanged. Signed-off-by: Guo Chen <[email protected]> * test(video-qa-rubric): run the MM-Lifelong v1.1 tests with the video_qa_rubric server tests The tests import the benchmarks' prepare.py and the video_qa_rubric server modules, so in the core suite they added those modules to the core coverage measurement. The video_qa_rubric server tests, which cover those modules, now run them. The tests are unchanged; they keep their repository root at parents[3]. Signed-off-by: Guo Chen <[email protected]> --------- Signed-off-by: Guo Chen <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: yaoyu-33 <[email protected]>
7 tasks done
This was referenced Nov 24, 2026
d-molinari
added a commit
that referenced
this pull request
Nov 24, 2026
Main's lock upgrade (#6528) moved the root lock, and `uv sync --locked` refused the sandboxed server's older lock, so neither its suite nor a run could start it. `uv lock` with uv 0.13.4 takes the root lock's versions (e2b 2.50.0, protobuf-py 0.1.1, pyqwest 0.10.0), keeps the tzdata OfficeEnv pins (2026.6), and passes scripts/component_locks.py. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]>
jkyi-nvidia
added a commit
that referenced
this pull request
Nov 25, 2026
…rors and parser speed - Refresh uv.lock for current main (root pins moved in #6528 and after). - Mask a verifier exception (mask_sample, failure_kind verifier_error) instead of scoring it 0; read_verdict no longer turns parser exceptions into bad_json. - pred_fields returns strings only, with lone surrogates replaced, so /verify never answers 500. - Remove reward_mode soft (unused); the reward is the gold_ladder match. gold_p_yes is provenance. - Strip the strict-mode fence by slicing and run the think regex only up to the last closing tag (both were quadratic on adversarial text; same results). - Name the ATS source file and commit of the copied code; add a RunRequest/TaskData drift test. - README: how labels are built, what each parse_error code covers. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Junkeun Yi <[email protected]>
ko3n1g
pushed a commit
to ko3n1g/Gym
that referenced
this pull request
Nov 30, 2026
…oxed harnesses (NVIDIA-NeMo#5010) * feat(single_agent_turn): drive the agent one step at a time and end the episode on the task state A resources server whose task ends through its state, rather than through one tool's call, can now have its episode end right after the step that ended the task. OfficeEnv's task ends when its user app's task row leaves pending, which several operations reach, depending on how a row exposes its apps. - single_agent_turn: max_episode_steps drives the agent one step per activation, up to that many steps, and end_on_task_state reads the resources session's task state between steps (GET /task_state, ResourcesTaskState in nemo_gym.server_runtime). Each step's failure report is kept. The server checks at startup that its agent keeps a session, runs the tools it calls and stops after one step. Driven episodes take part in checkpoints as restarts (BaseEnvironmentServer.checkpoint_mode_in_effect). - simple_agent: with x-ng-agent-episode-step-limit, a step stopped by its own one-step limit counts as completed unless it is the episode's last, and the session keeps one invocation for the episode, as the agent's own loop does, instead of one per step that repeats the whole history. - OfficeEnv: GET /task_state answers ResourcesTaskState; close_tools_on_task_end refuses the calls a step makes after the one that ended its task; its rows route by taskset to single_agent_turn with the step loop on, and the config allows only the simple agent. A retired attempt no longer keeps its episode, so its replacement can seed the same session ID. The server runs OfficeEnv 1.14.0 (1.13.0 at least), with its example rows emitted again. Signed-off-by: Daniele Molinari <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(single_agent_turn): run the step loop's tests in the core suite, and keep a simple_agent subclass in step CI on the step loop found two things: - agentic_turn_simulation_agent overrides simple_agent's _create_episode, which now takes step_limit_owned_by_caller. The override accepts it; only an agent session sets it, and this agent refuses those. - The core coverage gate counts single_agent_turn's and simple_agent's app.py, but the step loop's tests ran in the server suite only. They move to the core suite unchanged, and simple_agent's step limit and invocation folding get core tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(single_agent_turn): import each name in the moved step-loop tests from the module that defines it Tests under tests/ import from the defining module, not a package's public API, and test_the_librarys_tests_import_from_the_module_that_defines_each_name failed on the two files this PR moved into the core suite. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(simple_agent): one step per activation that names the episode's step limit, counted by its index With x-ng-agent-episode-step-limit, the agent takes one step (one model call and the tool calls it makes) whatever its max_steps says, so a pairing no longer needs max_steps: 1, which composition drops when --agent-type simple_agent replaces the environment's agent. Requests without the header run as before. - The step is the activation's index (x-ng-agent-activation), which such a caller sends with every step, not the count of requests, so a step resent after a dropped connection is not counted as the next one. - The session keeps the model server's cookies from step to step, so the episode keeps one model server session. - A step that raises ends the episode's folded invocation as failed (or incomplete when cancelled), not with the completed status of the step before. - The step keywords go to _create_episode only with the header, so an override that predates them keeps working; agentic_turn_simulation_agent's override no longer needs to accept one. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(single_agent_turn): drive only agents that take one step per activation, and keep what the steps did - STEP_DRIVEN_AGENT_TYPES (nemo_gym.config, beside AGENT_SESSION_AGENT_TYPES) lists the agent types that take one step per activation that names the episode's step limit: simple_agent. The startup check refuses any other type, such as hermes_agent or browsecomp_agent, which keep a session but run their own loop in an activation; a unit test keeps the list in step with the agent apps. The check no longer reads max_steps, and reads execute_tools as the agent's config does, so a string "false" is false. - A failure after a step completed keeps the completed steps, their output and summed usage, as its partial response, unless it already carries one; a failure before the first reply has none. - An episode that runs out of steps with every step calling a tool says so in its reply's metadata (ng_termination_reason: max_episode_steps). Its status stays the last step's: incomplete_details names only the model's own cutoffs, and an incomplete reply would read as malformed to rollout recovery. - The task state is not read after the last step, which ends the episode either way. - GET /task_state answering 404 with failure_kind session_lost ends the episode, which goes on to /verify and its masked lost-session result, as when a tool call finds the session gone. Other failed reads fail the episode as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(server_runtime): an environment server's checkpoint mode in effect sets its participant and its episodes A server whose class declares exported but whose instance runs as restart_only installs a restart_only participant, and its episodes begin as restarts; an unknown mode in effect stops the server at setup. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv): run on single_agent_turn_legacy, so flat rows and session-less agents run too single_agent_turn's /run takes only episode requests, so flat rows (training corpora, rows routed by their agent) failed. single_agent_turn_legacy takes flat rows and taskset episodes, and runs the same step loop: OfficeEnv keeps max_episode_steps 50, end_on_task_state, direct HTTP tools and the example taskset's route, and the simple agent no longer sets max_steps: 1. Composition's fallback relays an agent without agent sessions through legacy_agent to its own /run, so allowed_agents also admits simple_agent_with_compaction; the relay takes flat rows, not the taskset's episodes. The test that restated the YAML (skipped in CI with OfficeEnv absent) gives way to core tests that resolve the config with a model and build its environment server: as shipped, with simple_agent.yaml added as --agent-type simple_agent does, and with the compaction agent's config, where the server becomes a legacy_agent relay. The config comment and README say what --agent-type and allowed_agents do, and that rollout_recovery.target_level: sibling applies to the whole training run. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * docs: GET /task_state and the episode step-limit header The Seed/Verify Protocol Extensions table lists GET /task_state, its reply, and what a 404 or 5xx does to the episode. The agent integration page describes x-ng-agent-episode-step-limit beside x-ng-agent-activation. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(core): LentSandboxes lends a sandbox with its own image, environment and setup, and releases all within a deadline What the OfficeEnv sandboxed server needs from core's lent sandboxes, so it builds on them instead of a copy: - lend() takes a per-sandbox image, more environment variables and a setup that runs against the started sandbox, its files delivered, before it is lent (start_with_setup); a setup that fails stops the sandbox. - The start runs to its end once begun, within start_timeout_s (30 minutes by default), even while the request that asked for it is cancelled: a create cut in flight leaves a sandbox whose id the provider never returned. A lend cancelled meanwhile lends nothing and stops what it started, and says so in the log. - release_all(timeout_s=...) refuses new lends (503) from its start, waits for those still starting, stops everything within the deadline, and returns and logs the sessions whose sandbox may still run, for a reaper. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv): run OfficeEnv episodes in a sandbox, for Gym's sandboxed harnesses resources_servers/officeenv_sandbox's OfficeEnvSandboxResourcesServer subclasses the OfficeEnv server and lends each episode session a sandbox through LentSandboxes (an operate descriptor: the harness uses it, only the server stops it), stopped before the episode is graded. - The harness reaches the apps as the row's exposure says: MCP tools, a command per app (cli), or endpoints it finds over MCP and calls with curl (api_search). - File content stays out of the conversation through OfficeEnv's workspace mode: downloads land in the workspace, uploads and attachments name a workspace file, and a file API moves bytes directly. - The sandbox sees an ordinary company API. Only Gym's servers on this node (any of the node's own addresses) and trusted_networks reach seeding, closing, verification, metrics, the reverify mode, the app catalog, the task state and the tool routes, which answer others 404 before reading a body; sessions are signed with a per-process secret. - Seeds take turns, and a seed is admitted again before it lends; a close or a retire stops the sandbox, a failed seed's stop is tried again at its session's close, and shutdown stops everything within the run's grace. - A sandbox provider failure fails the call (502) and masks the episode's reward. - Configs for Pi (Docker and OpenSandbox), Codex CLI, mini-SWE, OpenCode, OpenClaw and Terminus 2; nine sandbox tasks (OfficeEnv 1.14.0), the first five as example rows with Pi's rollouts of them; images and a README. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(core): LentSandboxes logs a start its limit cut before the provider returned the sandbox's id When start_timeout_s cuts a provider's create in flight, the sandbox's id is unknown, so the lend's stop cannot reach what the create left. The lend now logs that cut at ERROR with the resources session, the task (id and taskset), the provider, the image and the labels, so a reaper can find the sandbox. A start cut after the create returned stops its sandbox as before and asks for no reaper. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * refactor(officeenv_sandbox): name each harness's instances after it, so harness configs compose in one run Every harness config defined `oe` and `single_agent_turn_legacy`, so two of them could not run together. Now: - the episodes' resources server is officeenv_sandbox_resources_server; - each config adds officeenv_sandbox_<harness>_agent (`_inherit_from` Gym's instance of the harness, as benchmarks do) and officeenv_sandbox_<harness>_environment_server (`_inherit_from: single_agent_turn_legacy`); - Pi, Codex and OpenCode, which name MCP tools their own way, run on their own copy of the episodes' server (officeenv_sandbox_<harness>_resources_server, `_copy` with its mcp_tool_prefix); the other harnesses run on the shared one. A copy takes the shared server's settings from the merged config, so one override reaches every harness. The interpolations, the documented overrides, the probe script and the README follow (a table of the names; the OpenSandbox config is listed after the other harness configs, since a later one pulls the episodes' config in again). A core test resolves each config alone and all six together with a model config, and replaces the server test that restated their YAML; it needs no OfficeEnv, so it runs in CI. The OpenCode and OpenClaw configs and the README no longer say those harnesses refuse MCP tool grants. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv_sandbox): sandbox_config.start_timeout_s bounds a sandbox's start; host_relay needs trusted_workstation - sandbox_config.start_timeout_s (1800 s by default, a finite number above 0) is passed to LentSandboxes, which fails the seed at that limit and logs a create it cut for a reaper. The README says when to raise it: creates on a busy OpenSandbox cell have taken up to 2,430 s. - host_relay forwards sandbox connections from the host's loopback, which the caller check takes for Gym's own servers, so code in a sandbox could call the routes kept for Gym for any session. Config validation now refuses host_relay unless sandbox_config.trusted_workstation is true, which a config sets only on a single-user workstation; its description and the README state the risk. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv_sandbox): officeenv_sandboxless.yaml runs the OfficeEnv server's instances under names of their own It composes resources_servers/officeenv/configs/officeenv.yaml and copies (`_copy`) its three instances as officeenv_sandboxless_resources_server, officeenv_sandbox_simple_agent and officeenv_sandbox_environment_server, each copy pointing at the other copies, while the OfficeEnv server's instances keep their names. The copied agent declares no dataset, so the example rows and their taskset stay with the OfficeEnv server's instances, and rows that name officeenv_sandbox_simple_agent (flat rows, agent_ref) route to the copied environment server. A `_copy` takes its source as written, before the source's own `_inherit_from` applies, so the environment server is copied as the instance of the server type officeenv_environment_server inherits, with that server's own settings for it on top. The core test checks each copy against its source, references aside, alone and beside the Pi and Codex configs, so a change to the source's server type fails it rather than leaving the copy behind. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv_sandbox): the sandboxless arm copies single_agent_turn_legacy, which the OfficeEnv server now runs officeenv_environment_server inherits single_agent_turn_legacy now, so the copy takes that instance, then the server's own settings for it under that type, with its references still pointing at the other copies. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * refactor(officeenv_sandbox): every harness runs the episodes' server under its own name, so none is left idle Each harness config now adds officeenv_sandbox_<harness>_resources_server with `_inherit_from: officeenv_sandbox_resources_server`, OpenClaw, mini-SWE and Terminus 2 included, and no harness names the episodes' server. `_inherit_from` reads it from the merged config and takes it out of the run, so a run of one or several harness configs starts no idle episodes' server, while the episodes config alone still runs it under its own name. Settings on the episodes' server, the OpenSandbox config's included, reach every harness's server. The OpenSandbox config still goes after the other harness configs (the first harness config listed pulls the episodes' config in), and the README now says why. The core test checks that no episodes' server starts or is named beside the harnesses', alone and with all six, and that the episodes config runs on its own. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(core): the cut-start log says OpenSandbox deletes what an abandoned create left Main's OpenSandbox provider now deletes the sandbox of a create its caller gave up on (NVIDIA-NeMo#4799), so a start that LentSandboxes' start_timeout_s cuts before the provider returned the sandbox's id no longer needs a reaper there. The ERROR log, LentSandboxes' docstring and the officeenv_sandbox README now say so, and keep the reaper for providers without that cleanup. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv_sandbox): Pi's run ends once its task has ended, on every exposure - The sandboxed server holds the call that ends a watched episode's task, on every way in (tools, commands, endpoints, the file API), until the environment server releases it; the episode's lock is let go first. Only Gym's node reaches GET /task_state and POST /task_state/release. - Pi supports POST /rollouts/{rollout_id}/stop (_rollout_sandbox_session): a run stopped as completed answers so, marked in ng_rollout_stop, and is not reported as a wall-time timeout. - The Pi config sets end_on_task_state on its environment server and drops finish_tool_names (now []): the stop ends the run on cli and api_search rows too, which offer no finish tool. Its comment no longer asks cli rows to drop the MCP transport, which they run with as it is. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * docs(officeenv): the servers run OfficeEnv 1.14.2 1.14.2 is the OfficeEnv release N4's training runs grade with. 1.14.1 and 1.14.2 are patch releases; neither changes the API these servers use. The READMEs' install lines name it, and the example rows are emitted again by it (officeenv emit for resources_servers/officeenv, sandbox/prepare_rows.py for officeenv_sandbox), which changed only their version stamp. The example rollouts stay the ones collected against 1.14.0. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv_sandbox): refuse calls after the task ended with ResourcesSessionConflictError Main's session contract (NVIDIA-NeMo#5691) has every 409 a resources server answers raise ResourcesSessionConflictError, and tests/unit_tests/test_session_contract_repo.py checks it. The sandboxed server refused a tool call once verification began, and a file API call once the episode's files closed, with plain HTTPException(409)s; both now raise the named error. The status and the detail are the same, so callers see no change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(core): LentSandboxes shields a start only with start_timeout_s Main's opencode_search (NVIDIA-NeMo#6211) lends through LentSandboxes and expects a seed cancelled while its sandbox starts to stop that sandbox at once, as LentSandboxes did before this branch; the shielded start made it wait for the start's end. The shield is now opt-in. Without start_timeout_s a cancel cuts the start as it cuts any await, as on main, and the lend stops the sandbox it began. With it, the start runs to its end within that limit, which the OfficeEnv sandbox server sets (sandbox_config.start_timeout_s, 1,800 s by default). START_TIMEOUT_S goes, since no default limit remains. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * build(officeenv_sandbox): lock against main's upgraded dependency locks Main's lock upgrade (NVIDIA-NeMo#6528) moved the root lock, and `uv sync --locked` refused the sandboxed server's older lock, so neither its suite nor a run could start it. `uv lock` with uv 0.13.4 takes the root lock's versions (e2b 2.50.0, protobuf-py 0.1.1, pyqwest 0.10.0), keeps the tzdata OfficeEnv pins (2026.6), and passes scripts/component_locks.py. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(core): a cut start's test counts the closes the provider made Main's NVIDIA-NeMo#6410 changed the stopped fixture from AsyncSandbox.stop calls to the closes the provider made. A start cut before the provider returned its sandbox's id leaves nothing to close, so the hung-start test now expects none, as the ERROR line it checks says. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(single_agent_turn): stop an agent's own loop once its task has ended With end_on_task_state and no max_episode_steps, single_agent_turn now ends an agent that runs its own loop (a sandboxed harness) at its task's end, as the step loop ends a step-driven one: - Before the agent runs it reads GET /task_state?watch=true; while the agent runs it reads again, each read waiting up to 30 s (wait_s). - Once the task has ended it stops the run with POST /rollouts/{id}/stop {"reason": "task_ended", "completed": true}, waits for the activation to answer (at most 120 s), then posts /task_state/release. - The resources server holds its answer to the call that ended the task until that release, so the harness never reads it while its run could go on, and no model call follows the call that ended the task. - The server refuses at startup an agent type outside ROLLOUT_STOP_AGENT_TYPES (the agents whose runs the stop route can end; a unit test keeps the list in step with the apps). Core: RolloutStopRequest.completed; such a stop answers as completed (report_rollout_stop) and says so in ng_rollout_stop. Docker uploads take a bound of their own, so a stop's marker never waits for the exec slot a running harness holds (uploads_independent_of_execs). OfficeEnv: GET /task_state takes watch and wait_s (at most 60 s); POST /task_state/release; task_end_hold_seconds (180) bounds the hold. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(officeenv_sandbox): the stand-in sandbox stops as main's AsyncSandbox.stop does Main's NVIDIA-NeMo#6410 moved the shielded, bounded stop into AsyncSandbox.stop(timeout_s=...), which LentSandboxes now calls. The tests' FakeSandbox.stop took no timeout_s and had no shield, so a seed or close cancelled during a stop failed or hung. FakeSandbox.stop now takes timeout_s and shields its provider-side _stop, as AsyncSandbox.stop does, and the tests that slow down, refuse or hang a stop patch _stop. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(cline_agent): the fake sandbox session carries expire_completed report_rollout_stop now reads SandboxSession.expire_completed (a run stopped once its task has ended answers as completed), so the stand-in that Cline's session tests use carries it too, as the real session does. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * refactor(officeenv_sandbox): sign sessions with Gym's run secret NVIDIA-NeMo#6161 now makes a secret per server and run in server_runtime, which every worker of the server shares (signs_sessions_with_run_secret). The sandboxed server sets that flag instead of minting its own secret in model_post_init and overriding get_session_secret(): its cookies and MCP tokens are signed, as before, with a secret code in a sandbox cannot derive from the server's name. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv): refuse a tool call after the task ended with ResourcesSessionConflictError Main's session contract (NVIDIA-NeMo#5691) has every 409 a resources server answers raise ResourcesSessionConflictError, and tests/unit_tests/test_session_contract_repo.py checks it. With close_tools_on_task_end, the OfficeEnv server refused a call after the task ended with a plain HTTPException(409); it now raises the named error. The status and the detail are the same, so callers see no change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(core): release_all stops the lent sandboxes while a lend is still starting release_all waited for every start in flight before it stopped any lent sandbox, all inside one time limit. One slow start at shutdown then left every lent sandbox running until its TTL. Now the lent sandboxes stop at once, and each starting sandbox is stopped when its start ends. The new test fails before this change (no sandbox stopped) and passes after it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(officeenv_sandbox): keep the agent and environment servers on 127.0.0.1 NeMo RL sets default_host to the node's address, and an explicit default_host applies to every server, not only to the types in absolute_ip_server_types. A sandbox's network rule opens every port of an allowed host. So code in a sandbox could call the agent and environment servers: run Pi on Gym's host (/v1/responses without a session), start episodes (/run) and stop another episode's run (/rollouts/{rollout_id}/stop). Each harness config now sets host: 127.0.0.1 on its agent and its environment server. No sandbox calls them: each harness in a sandbox calls only the model server and the resources server, and NeMo RL calls /run from the same node. Without default_host, Gym already binds them to 127.0.0.1. The comment in officeenv_opensandbox.yaml and the README now say this. The new config test resolves every harness config under default_host: 10.0.0.5, on Docker and on OpenSandbox. It fails before this change (the agent server gets 10.0.0.5) and passes after it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(officeenv_sandbox): refuse calls after the task ends for every harness No sandboxed config set close_tools_on_task_end, though the README said that it refuses a harness's later calls. Only Pi's environment server stops the run at the task's end. So under Codex, OpenCode, OpenClaw, mini-SWE and Terminus 2, a tool or file API call after complete_task could still change what /verify grades: a late upload made a task pass. The episodes' config, which every harness's resources server inherits, now sets close_tools_on_task_end: true. The config test asserts the resolved value for each harness in every composition. It fails before this change and passes after it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * refactor(officeenv_sandbox): leave the mini-SWE pairing to a follow-up PR The mini-SWE config ran on miniswe_sandboxed_agent, which is deprecated for new configs in favor of mini_swe_agent's agent sessions. A follow-up PR will add the pairing on mini_swe_agent/mini_swe_agent_sandboxed, with one real `cli` row. This removes configs/officeenv_sandbox_miniswe.yaml, its rows in both config tests and its mentions in the README. The other five harness configs are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(single_agent_turn): make the task-end stop reach the agent and fail for good on 501 The stop that ends an agent's own loop at the task end now: - goes over the reserved control connection pool, with the release, so it never waits for a connection that the running activation holds; - counts its 120 s bound from the time the stop is sent, and waits for the activation also when the stop answers stopped: false; - logs a warning and marks the reply (ng_task_end_stop: unconfirmed) when the activation still runs at that bound; - fails the episode for good when the agent answers 501 (the sandbox provider cannot stop a running harness), since every attempt would fail the same way. 500 and 502 stay retryable. A task that has already ended, or a lost resources session, at the first watch starts no run: the episode goes on to verification with a reply that has no output (ng_termination_reason: task_ended_before_run). The step loop logs a warning at startup when the driven agent sets max_steps, which it does not use. The single_agent_turn README names bwrap among the providers that can stop a running harness, and the providers whose stop answers 501. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(officeenv): report tool_drift for episode seeds, and document close_tools_on_task_end An episode seed (ResourcesSeedSessionRequest) now passes the task's responses_create_params to OfficeEnv with the row, as a seed of the whole row did through legacy_agent, so tool_drift is reported again for rows whose tools are stale. The README no longer says that checks read every message sent after complete_task: with close_tools_on_task_end, which this configuration turns on, such a call gets 409 and changes nothing. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * docs(agent-server): describe completed rollout stops and the providers that can stop a running harness The harness guide now names RolloutStopRequest.completed and the completed status it gives a stopped run, and lists Local, bwrap, Docker and OpenSandbox with background_exec as the providers that can stop a running harness. The others answer HTTP 501. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(officeenv_sandbox): report tool_drift for episode seeds NVIDIA-NeMo#6162 makes the OfficeEnv server's episode seed keep the task's responses_create_params, so tool_drift compares the row's tools with the ones the server serves. This server overrides _new_episode with the same task_data-only seed, so it reported no drift for an episode seed. It now passes responses_create_params the same way. The new test seeds a row whose first tool has a stale description. It fails before this change (tool_drift 0.0) and passes after it (1.0). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(simple_agent): run a caller-driven step once when it is sent again Without checkpointing, the environment server's client sends a step again after a dropped connection, and the step ran its model call and tool calls a second time: a second email, say, while the environment recorded one reply. A step of a session that a caller drives one step per activation (x-ng-agent-episode-step-limit) is now keyed by its session and its activation index. A step sent again while it runs shares its run, and one sent after it answered gets the same reply and cookies; neither calls the model or runs a tool again. The step runs apart from the request that sent it, so a disconnect that cancels that request does not cut it short, and closing the session cancels a step that still runs. A step older than the session's latest is refused with 409. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(agents): a run stopped as completed closes with its invocation completed A stop with completed: true, for a run whose task ended, makes the run's response completed (report_rollout_stop), but the harness agents record their invocation before that, as incomplete. So the same run had two statuses: completed in its response and incomplete in its agent observations (for Prime, and for every agent in ROLLOUT_STOP_AGENT_TYPES). The base agent's session close now applies report_completed_rollout_stop when the rollout's sandbox session ended with a completed stop: each top-level invocation the stop left incomplete says completed, with no error type. The sandbox observation keeps the supervisor's raw timeout, and a child invocation keeps its own status. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * docs(agent-server): a step sent again runs once, and a completed stop closes completed The integration guide says that simple_agent runs a caller-driven step once without checkpointing, and that the session close of a run stopped as completed reports its top-level invocation as completed. The harness guide says the same of the close. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(simple_agent): drop a session's saved step when it closes The close now clears the step the session kept for a step sent again, so a session never keeps it after it ends. The docstring says why only caller-driven steps without checkpointing need it: with checkpointing, the activation tracking already gives a repeated activation its saved reply, and any other activation is the episode's only one or a continuation session's turn on new input. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * test(goose_agent): a stop for an ended task closes with the invocation completed A second agent from ROLLOUT_STOP_AGENT_TYPES, besides Prime, whose close after a completed stop has the shape the base close fixes: a top-level invocation left incomplete, which report_completed_rollout_stop marks completed, and a sandbox observation that keeps the supervisor's timeout. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * build(officeenv_sandbox): lock against main's bumped root dependencies CI tests this branch merged onto NVIDIA-NeMo#6162's merge ref with main. Main's NVIDIA-NeMo#6268 bumped hydra-core (>=1.4.0rc3), omegaconf (>=2.4.1rc2), mlflow and gitpython in the root pyproject, which this server's lock includes through nemo-gym. So `uv sync --locked` and the lock check refused this lock in CI. This lock was made with `uv lock` on a tree shaped like CI's: this branch merged onto NVIDIA-NeMo#6162's merge ref 5c7691f (942c31a on main 6aa1fd6). There, `uv lock --check` and `uv sync --locked` pass, and the server's tests pass. On this branch alone, `uv lock --check` fails until NVIDIA-NeMo#6162 contains main, because the branch still has the older root pyproject. The lock is the one that is right once NVIDIA-NeMo#6162 has main. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(single_agent_turn): keep task-end watches and stops progressing Signed-off-by: yaoyu-33 <[email protected]> * fix(officeenv_sandbox): bind sandboxless services to loopback Signed-off-by: yaoyu-33 <[email protected]> * fix(pi): report task-end stops after classifying the invocation Signed-off-by: yaoyu-33 <[email protected]> * chore(officeenv_sandbox): add the test package license header Signed-off-by: yaoyu-33 <[email protected]> --------- Signed-off-by: Daniele Molinari <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Yi-Fu Wu <[email protected]> Co-authored-by: yaoyu-33 <[email protected]>
yaoyu-33
added a commit
to yaoyu-33/Gym
that referenced
this pull request
Dec 1, 2026
…ion to keep the recorded history (NVIDIA-NeMo#6672) * feat(core): session secrets, cookie names and MCP endpoint options for servers that sandboxed code calls A resources server that lends a sandbox is reached by code the model controls, so the session key that every caller can compute from the server's class and name must not sign its cookies and MCP tokens, and its endpoint should look like an ordinary one. - SimpleServer.get_session_secret() signs session cookies and MCP session tokens (default: the session middleware key, so nothing changes). Session routing reads cookies and tokens with it. Its docstring states what an override must keep: one secret in every worker, and a secret that changes ends every open session. - SimpleServer.get_session_cookie_name() names the session cookie (default: the same key). - mcp_server_name: the name the MCP endpoint lists itself under; verify-time normalization strips its namespace. - mcp_bearer_token: tokens ride as Authorization: Bearer, tools/list needs one and lists only the session's tools, a tool outside the grant is an unknown tool, and errors name no framework. - Both options are refused without expose_tools_over_mcp, and a name outside MCP's tool-name alphabet is refused. A single_agent_turn pairing refuses to grant two MCP endpoints listed under one name. Signed-off-by: Daniele Molinari <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(server_runtime): honor mcp_server_name end to end and refuse bearer tokens without a secret Review fixes for the MCP endpoint options. - mcp_server_name is also checked against the name pattern of an MCP grant (MCP_TOOL_ACCESS_NAME_PATTERN in tool_access, which MCPToolAccess uses), so a name that an Environment Server cannot grant, one that starts with '_' or '-', is refused at config instead of failing every episode before the agent seed. The grant contract is unchanged. A dot stays refused: Pi's MCP adapter and Codex refuse server names outside [A-Za-z0-9_-]. - seed_mcp_servers keys each entry by the seed metadata's server_name, else the server's name, and refuses two servers listed under one name. URLs, headers and routing still use the server's reference. The sandboxed OpenCode agent's required-server list uses the same keys; the sandboxed Pi agent reads them as given. - An MCP endpoint with mcp_bearer_token refuses to start while get_session_secret() is the public session middleware key, since code that reads one bearer token could sign another session's. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * revert(agents): keep MCP endpoint names off the legacy seeder Review asked to keep the MCP changes on the agent-session path. The only callers of seed_mcp_servers, the sandboxed Pi and OpenCode agents, run on the agent-owned /run path that #5222 deprecates, and OfficeEnv's Pi preset gets the advertised name and headers through its MCPToolAccess grant. The seeder keys its entries by server name again, and the aliasing's tests go with it. It no longer refuses two servers under one name, a refusal that came after the primary server may have started a task sandbox and before OpenCode's cleanup. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(opencode_agent): refuse MCP grants whose tools OpenCode could name alike Review found that distinct endpoint names can still hide a tool in opencode_agent. OpenCode keys each MCP tool <grant>_<tool>, writing characters outside [a-zA-Z0-9_-] as '_', and a later tool under a key already taken replaces the earlier one without a word: `company` serving `files_list` and `company_files` serving `list` both register `company_files_list`. The agent's seed now refuses two MCP grants whose tools could share a key, which the grant names decide: equal once written as OpenCode writes them, or one the other followed by '_'. single_agent_turn's README and check, and the mcp_server_name field, describe tool naming as each harness's own. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(server_runtime): sign sessions with a secret made for the run Review asked for per-run session secrets in server_runtime, as episode_token_secret() does (#5346), instead of each server overriding get_session_secret(). run_session_secret(name) makes one secret per server for the run and keeps it in the environment, so the workers uvicorn starts after the main process built the server inherit it. get_session_secret() returns it when the server sets signs_sessions_with_run_secret or its config sets mcp_bearer_token, so bearer tokens work from YAML alone and with any number of workers; otherwise it is the public key, as before. The session_secret property resolves it once per server (a cached_property, so it holds for a server built without its model_post_init too), and the session middleware, session routing and the MCP endpoint all read it there, so an override that answers differently from call to call cannot split them. Exposure still refuses bearer tokens signed with the public key, which only an override can now produce. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(single_agent_turn): drive the agent one step at a time and end the episode on the task state A resources server whose task ends through its state, rather than through one tool's call, can now have its episode end right after the step that ended the task. OfficeEnv's task ends when its user app's task row leaves pending, which several operations reach, depending on how a row exposes its apps. - single_agent_turn: max_episode_steps drives the agent one step per activation, up to that many steps, and end_on_task_state reads the resources session's task state between steps (GET /task_state, ResourcesTaskState in nemo_gym.server_runtime). Each step's failure report is kept. The server checks at startup that its agent keeps a session, runs the tools it calls and stops after one step. Driven episodes take part in checkpoints as restarts (BaseEnvironmentServer.checkpoint_mode_in_effect). - simple_agent: with x-ng-agent-episode-step-limit, a step stopped by its own one-step limit counts as completed unless it is the episode's last, and the session keeps one invocation for the episode, as the agent's own loop does, instead of one per step that repeats the whole history. - OfficeEnv: GET /task_state answers ResourcesTaskState; close_tools_on_task_end refuses the calls a step makes after the one that ended its task; its rows route by taskset to single_agent_turn with the step loop on, and the config allows only the simple agent. A retired attempt no longer keeps its episode, so its replacement can seed the same session ID. The server runs OfficeEnv 1.14.0 (1.13.0 at least), with its example rows emitted again. Signed-off-by: Daniele Molinari <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(single_agent_turn): run the step loop's tests in the core suite, and keep a simple_agent subclass in step CI on the step loop found two things: - agentic_turn_simulation_agent overrides simple_agent's _create_episode, which now takes step_limit_owned_by_caller. The override accepts it; only an agent session sets it, and this agent refuses those. - The core coverage gate counts single_agent_turn's and simple_agent's app.py, but the step loop's tests ran in the server suite only. They move to the core suite unchanged, and simple_agent's step limit and invocation folding get core tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(single_agent_turn): import each name in the moved step-loop tests from the module that defines it Tests under tests/ import from the defining module, not a package's public API, and test_the_librarys_tests_import_from_the_module_that_defines_each_name failed on the two files this PR moved into the core suite. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(simple_agent): one step per activation that names the episode's step limit, counted by its index With x-ng-agent-episode-step-limit, the agent takes one step (one model call and the tool calls it makes) whatever its max_steps says, so a pairing no longer needs max_steps: 1, which composition drops when --agent-type simple_agent replaces the environment's agent. Requests without the header run as before. - The step is the activation's index (x-ng-agent-activation), which such a caller sends with every step, not the count of requests, so a step resent after a dropped connection is not counted as the next one. - The session keeps the model server's cookies from step to step, so the episode keeps one model server session. - A step that raises ends the episode's folded invocation as failed (or incomplete when cancelled), not with the completed status of the step before. - The step keywords go to _create_episode only with the header, so an override that predates them keeps working; agentic_turn_simulation_agent's override no longer needs to accept one. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(single_agent_turn): drive only agents that take one step per activation, and keep what the steps did - STEP_DRIVEN_AGENT_TYPES (nemo_gym.config, beside AGENT_SESSION_AGENT_TYPES) lists the agent types that take one step per activation that names the episode's step limit: simple_agent. The startup check refuses any other type, such as hermes_agent or browsecomp_agent, which keep a session but run their own loop in an activation; a unit test keeps the list in step with the agent apps. The check no longer reads max_steps, and reads execute_tools as the agent's config does, so a string "false" is false. - A failure after a step completed keeps the completed steps, their output and summed usage, as its partial response, unless it already carries one; a failure before the first reply has none. - An episode that runs out of steps with every step calling a tool says so in its reply's metadata (ng_termination_reason: max_episode_steps). Its status stays the last step's: incomplete_details names only the model's own cutoffs, and an incomplete reply would read as malformed to rollout recovery. - The task state is not read after the last step, which ends the episode either way. - GET /task_state answering 404 with failure_kind session_lost ends the episode, which goes on to /verify and its masked lost-session result, as when a tool call finds the session gone. Other failed reads fail the episode as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(server_runtime): an environment server's checkpoint mode in effect sets its participant and its episodes A server whose class declares exported but whose instance runs as restart_only installs a restart_only participant, and its episodes begin as restarts; an unknown mode in effect stops the server at setup. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv): run on single_agent_turn_legacy, so flat rows and session-less agents run too single_agent_turn's /run takes only episode requests, so flat rows (training corpora, rows routed by their agent) failed. single_agent_turn_legacy takes flat rows and taskset episodes, and runs the same step loop: OfficeEnv keeps max_episode_steps 50, end_on_task_state, direct HTTP tools and the example taskset's route, and the simple agent no longer sets max_steps: 1. Composition's fallback relays an agent without agent sessions through legacy_agent to its own /run, so allowed_agents also admits simple_agent_with_compaction; the relay takes flat rows, not the taskset's episodes. The test that restated the YAML (skipped in CI with OfficeEnv absent) gives way to core tests that resolve the config with a model and build its environment server: as shipped, with simple_agent.yaml added as --agent-type simple_agent does, and with the compaction agent's config, where the server becomes a legacy_agent relay. The config comment and README say what --agent-type and allowed_agents do, and that rollout_recovery.target_level: sibling applies to the whole training run. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * docs: GET /task_state and the episode step-limit header The Seed/Verify Protocol Extensions table lists GET /task_state, its reply, and what a 404 or 5xx does to the episode. The agent integration page describes x-ng-agent-episode-step-limit beside x-ng-agent-activation. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(single_agent_turn): stop an agent's own loop once its task has ended With end_on_task_state and no max_episode_steps, single_agent_turn now ends an agent that runs its own loop (a sandboxed harness) at its task's end, as the step loop ends a step-driven one: - Before the agent runs it reads GET /task_state?watch=true; while the agent runs it reads again, each read waiting up to 30 s (wait_s). - Once the task has ended it stops the run with POST /rollouts/{id}/stop {"reason": "task_ended", "completed": true}, waits for the activation to answer (at most 120 s), then posts /task_state/release. - The resources server holds its answer to the call that ended the task until that release, so the harness never reads it while its run could go on, and no model call follows the call that ended the task. - The server refuses at startup an agent type outside ROLLOUT_STOP_AGENT_TYPES (the agents whose runs the stop route can end; a unit test keeps the list in step with the apps). Core: RolloutStopRequest.completed; such a stop answers as completed (report_rollout_stop) and says so in ng_rollout_stop. Docker uploads take a bound of their own, so a stop's marker never waits for the exec slot a running harness holds (uploads_independent_of_execs). OfficeEnv: GET /task_state takes watch and wait_s (at most 60 s); POST /task_state/release; task_end_hold_seconds (180) bounds the hold. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(cline_agent): the fake sandbox session carries expire_completed report_rollout_stop now reads SandboxSession.expire_completed (a run stopped once its task has ended answers as completed), so the stand-in that Cline's session tests use carries it too, as the real session does. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv): refuse a tool call after the task ended with ResourcesSessionConflictError Main's session contract (#5691) has every 409 a resources server answers raise ResourcesSessionConflictError, and tests/unit_tests/test_session_contract_repo.py checks it. With close_tools_on_task_end, the OfficeEnv server refused a call after the task ended with a plain HTTPException(409); it now raises the named error. The status and the detail are the same, so callers see no change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(core): LentSandboxes lends a sandbox with its own image, environment and setup, and releases all within a deadline What the OfficeEnv sandboxed server needs from core's lent sandboxes, so it builds on them instead of a copy: - lend() takes a per-sandbox image, more environment variables and a setup that runs against the started sandbox, its files delivered, before it is lent (start_with_setup); a setup that fails stops the sandbox. - The start runs to its end once begun, within start_timeout_s (30 minutes by default), even while the request that asked for it is cancelled: a create cut in flight leaves a sandbox whose id the provider never returned. A lend cancelled meanwhile lends nothing and stops what it started, and says so in the log. - release_all(timeout_s=...) refuses new lends (503) from its start, waits for those still starting, stops everything within the deadline, and returns and logs the sessions whose sandbox may still run, for a reaper. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv): run OfficeEnv episodes in a sandbox, for Gym's sandboxed harnesses resources_servers/officeenv_sandbox's OfficeEnvSandboxResourcesServer subclasses the OfficeEnv server and lends each episode session a sandbox through LentSandboxes (an operate descriptor: the harness uses it, only the server stops it), stopped before the episode is graded. - The harness reaches the apps as the row's exposure says: MCP tools, a command per app (cli), or endpoints it finds over MCP and calls with curl (api_search). - File content stays out of the conversation through OfficeEnv's workspace mode: downloads land in the workspace, uploads and attachments name a workspace file, and a file API moves bytes directly. - The sandbox sees an ordinary company API. Only Gym's servers on this node (any of the node's own addresses) and trusted_networks reach seeding, closing, verification, metrics, the reverify mode, the app catalog, the task state and the tool routes, which answer others 404 before reading a body; sessions are signed with a per-process secret. - Seeds take turns, and a seed is admitted again before it lends; a close or a retire stops the sandbox, a failed seed's stop is tried again at its session's close, and shutdown stops everything within the run's grace. - A sandbox provider failure fails the call (502) and masks the episode's reward. - Configs for Pi (Docker and OpenSandbox), Codex CLI, mini-SWE, OpenCode, OpenClaw and Terminus 2; nine sandbox tasks (OfficeEnv 1.14.0), the first five as example rows with Pi's rollouts of them; images and a README. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(core): LentSandboxes logs a start its limit cut before the provider returned the sandbox's id When start_timeout_s cuts a provider's create in flight, the sandbox's id is unknown, so the lend's stop cannot reach what the create left. The lend now logs that cut at ERROR with the resources session, the task (id and taskset), the provider, the image and the labels, so a reaper can find the sandbox. A start cut after the create returned stops its sandbox as before and asks for no reaper. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * refactor(officeenv_sandbox): name each harness's instances after it, so harness configs compose in one run Every harness config defined `oe` and `single_agent_turn_legacy`, so two of them could not run together. Now: - the episodes' resources server is officeenv_sandbox_resources_server; - each config adds officeenv_sandbox_<harness>_agent (`_inherit_from` Gym's instance of the harness, as benchmarks do) and officeenv_sandbox_<harness>_environment_server (`_inherit_from: single_agent_turn_legacy`); - Pi, Codex and OpenCode, which name MCP tools their own way, run on their own copy of the episodes' server (officeenv_sandbox_<harness>_resources_server, `_copy` with its mcp_tool_prefix); the other harnesses run on the shared one. A copy takes the shared server's settings from the merged config, so one override reaches every harness. The interpolations, the documented overrides, the probe script and the README follow (a table of the names; the OpenSandbox config is listed after the other harness configs, since a later one pulls the episodes' config in again). A core test resolves each config alone and all six together with a model config, and replaces the server test that restated their YAML; it needs no OfficeEnv, so it runs in CI. The OpenCode and OpenClaw configs and the README no longer say those harnesses refuse MCP tool grants. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv_sandbox): sandbox_config.start_timeout_s bounds a sandbox's start; host_relay needs trusted_workstation - sandbox_config.start_timeout_s (1800 s by default, a finite number above 0) is passed to LentSandboxes, which fails the seed at that limit and logs a create it cut for a reaper. The README says when to raise it: creates on a busy OpenSandbox cell have taken up to 2,430 s. - host_relay forwards sandbox connections from the host's loopback, which the caller check takes for Gym's own servers, so code in a sandbox could call the routes kept for Gym for any session. Config validation now refuses host_relay unless sandbox_config.trusted_workstation is true, which a config sets only on a single-user workstation; its description and the README state the risk. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv_sandbox): officeenv_sandboxless.yaml runs the OfficeEnv server's instances under names of their own It composes resources_servers/officeenv/configs/officeenv.yaml and copies (`_copy`) its three instances as officeenv_sandboxless_resources_server, officeenv_sandbox_simple_agent and officeenv_sandbox_environment_server, each copy pointing at the other copies, while the OfficeEnv server's instances keep their names. The copied agent declares no dataset, so the example rows and their taskset stay with the OfficeEnv server's instances, and rows that name officeenv_sandbox_simple_agent (flat rows, agent_ref) route to the copied environment server. A `_copy` takes its source as written, before the source's own `_inherit_from` applies, so the environment server is copied as the instance of the server type officeenv_environment_server inherits, with that server's own settings for it on top. The core test checks each copy against its source, references aside, alone and beside the Pi and Codex configs, so a change to the source's server type fails it rather than leaving the copy behind. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv_sandbox): the sandboxless arm copies single_agent_turn_legacy, which the OfficeEnv server now runs officeenv_environment_server inherits single_agent_turn_legacy now, so the copy takes that instance, then the server's own settings for it under that type, with its references still pointing at the other copies. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * refactor(officeenv_sandbox): every harness runs the episodes' server under its own name, so none is left idle Each harness config now adds officeenv_sandbox_<harness>_resources_server with `_inherit_from: officeenv_sandbox_resources_server`, OpenClaw, mini-SWE and Terminus 2 included, and no harness names the episodes' server. `_inherit_from` reads it from the merged config and takes it out of the run, so a run of one or several harness configs starts no idle episodes' server, while the episodes config alone still runs it under its own name. Settings on the episodes' server, the OpenSandbox config's included, reach every harness's server. The OpenSandbox config still goes after the other harness configs (the first harness config listed pulls the episodes' config in), and the README now says why. The core test checks that no episodes' server starts or is named beside the harnesses', alone and with all six, and that the episodes config runs on its own. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(core): the cut-start log says OpenSandbox deletes what an abandoned create left Main's OpenSandbox provider now deletes the sandbox of a create its caller gave up on (#4799), so a start that LentSandboxes' start_timeout_s cuts before the provider returned the sandbox's id no longer needs a reaper there. The ERROR log, LentSandboxes' docstring and the officeenv_sandbox README now say so, and keep the reaper for providers without that cleanup. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv_sandbox): Pi's run ends once its task has ended, on every exposure - The sandboxed server holds the call that ends a watched episode's task, on every way in (tools, commands, endpoints, the file API), until the environment server releases it; the episode's lock is let go first. Only Gym's node reaches GET /task_state and POST /task_state/release. - Pi supports POST /rollouts/{rollout_id}/stop (_rollout_sandbox_session): a run stopped as completed answers so, marked in ng_rollout_stop, and is not reported as a wall-time timeout. - The Pi config sets end_on_task_state on its environment server and drops finish_tool_names (now []): the stop ends the run on cli and api_search rows too, which offer no finish tool. Its comment no longer asks cli rows to drop the MCP transport, which they run with as it is. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * docs(officeenv): the servers run OfficeEnv 1.14.2 1.14.2 is the OfficeEnv release N4's training runs grade with. 1.14.1 and 1.14.2 are patch releases; neither changes the API these servers use. The READMEs' install lines name it, and the example rows are emitted again by it (officeenv emit for resources_servers/officeenv, sandbox/prepare_rows.py for officeenv_sandbox), which changed only their version stamp. The example rollouts stay the ones collected against 1.14.0. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv_sandbox): refuse calls after the task ended with ResourcesSessionConflictError Main's session contract (#5691) has every 409 a resources server answers raise ResourcesSessionConflictError, and tests/unit_tests/test_session_contract_repo.py checks it. The sandboxed server refused a tool call once verification began, and a file API call once the episode's files closed, with plain HTTPException(409)s; both now raise the named error. The status and the detail are the same, so callers see no change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(core): LentSandboxes shields a start only with start_timeout_s Main's opencode_search (#6211) lends through LentSandboxes and expects a seed cancelled while its sandbox starts to stop that sandbox at once, as LentSandboxes did before this branch; the shielded start made it wait for the start's end. The shield is now opt-in. Without start_timeout_s a cancel cuts the start as it cuts any await, as on main, and the lend stops the sandbox it began. With it, the start runs to its end within that limit, which the OfficeEnv sandbox server sets (sandbox_config.start_timeout_s, 1,800 s by default). START_TIMEOUT_S goes, since no default limit remains. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * build(officeenv_sandbox): lock against main's upgraded dependency locks Main's lock upgrade (#6528) moved the root lock, and `uv sync --locked` refused the sandboxed server's older lock, so neither its suite nor a run could start it. `uv lock` with uv 0.13.4 takes the root lock's versions (e2b 2.50.0, protobuf-py 0.1.1, pyqwest 0.10.0), keeps the tzdata OfficeEnv pins (2026.6), and passes scripts/component_locks.py. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(core): a cut start's test counts the closes the provider made Main's #6410 changed the stopped fixture from AsyncSandbox.stop calls to the closes the provider made. A start cut before the provider returned its sandbox's id leaves nothing to close, so the hung-start test now expects none, as the ERROR line it checks says. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(officeenv_sandbox): the stand-in sandbox stops as main's AsyncSandbox.stop does Main's #6410 moved the shielded, bounded stop into AsyncSandbox.stop(timeout_s=...), which LentSandboxes now calls. The tests' FakeSandbox.stop took no timeout_s and had no shield, so a seed or close cancelled during a stop failed or hung. FakeSandbox.stop now takes timeout_s and shields its provider-side _stop, as AsyncSandbox.stop does, and the tests that slow down, refuse or hang a stop patch _stop. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * refactor(officeenv_sandbox): sign sessions with Gym's run secret #6161 now makes a secret per server and run in server_runtime, which every worker of the server shares (signs_sessions_with_run_secret). The sandboxed server sets that flag instead of minting its own secret in model_post_init and overriding get_session_secret(): its cookies and MCP tokens are signed, as before, with a secret code in a sandbox cannot derive from the server's name. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(stirrup_agent): stop a run once its task has ended, and run Stirrup on OfficeEnv's sandboxed episodes Stirrup could not be stopped in flight, so single_agent_turn's end_on_task_state refused it and OfficeEnv's sandboxed episodes had no Stirrup harness: - stirrup_agent returns its sandbox session for a rollout stop (_rollout_sandbox_session) and marks the run a stop ended (report_rollout_stop): a stop once the task has ended answers as completed, with ng_rollout_stop and without the deadline's stop_reason. stirrup_agent joins ROLLOUT_STOP_AGENT_TYPES. - The runner, ended by its supervisor while a turn's tool calls run, reports that turn's reply too (its calls without answers) rather than the history as of the turn's start. A stop once the task has ended lands so: the call that ended the task waits for its answer until the run is over, and it stays the run's last item, as Pi's does. - resources_servers/officeenv_sandbox/configs/officeenv_sandbox_stirrup.yaml: Stirrup on `cli` rows, under the harness configs' names (officeenv_sandbox_stirrup_agent, _environment_server, _resources_server), no MCP transports, end_on_task_state, admitted episodes capped at Stirrup's concurrency. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * feat(stirrup_agent): options to keep the run's history as it was recorded Training on recorded tokens needs one unbroken history per episode, and Stirrup's defaults rewrite it: past 0.7 of the context window it replaces the history with a summary, and on a context overflow it unwinds completed turns. Two options keep those defaults and let a training config turn them off: - context_summarization_cutoff (default 0.7, Stirrup's): None never summarizes, so an episode at the context limit ends there; - recover_from_context_overflow (default true, Stirrup's): false raises instead of unwinding. The runner passes them to Stirrup's agent; a payload without them keeps Stirrup's defaults. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * test(officeenv_sandbox): cover the Stirrup harness config in the core config tests The server's own config tests skip without OfficeEnv, and CI does not install OfficeEnv. The core config tests resolve each harness config without it, so they now include officeenv_sandbox_stirrup.yaml. The tests make sure that its instances carry Stirrup's name, that it composes beside the other harness configs with its own cap of 32, and that its environment server stops the run once the task has ended. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * docs(stirrup_agent): describe rollout stops and the history options The README now says how a rollout stop ends a Stirrup run and what the response carries. A run that ends while a turn's tool calls run ends with that turn's reply. The options table lists context_summarization_cutoff and recover_from_context_overflow, and a new section names the settings that keep the recorded history for training. With context_overflow_recovery off, its default, the client never reports an overflow to Stirrup. So recover_from_context_overflow changes a run only when a config also turns context_overflow_recovery on. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(stirrup_agent): keep a compaction summary out of a stopped run's output The runner kept the last reply of every model call, a compaction summary's included. A summary can carry tool calls, since its first attempts offer the tools. If the run then ended while the next policy call waited for the model, the runner added the summary and its calls to the output as the running turn, although those calls never ran. The runner now keeps only the reply of the policy turn that is running. Each model call clears the reply first, and a reply made during a compaction is never kept. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(stirrup_agent): answer a stop that arrives before the runner starts A rollout stop accepted during the seed or before the activation keeps the supervisor from launching the runner. The runner then writes no output.json, so the activation failed with "Stirrup sandbox runner exited without output", although the agent server had answered the stop as stopped. When the session reports an expiry before launch, the runner's report is now an empty run that ended at its time limit, with the session's cookies. The agent server then marks the stop and gives the status the stop asked for, as for a run that a stop ended. Missing output from a runner that did launch still fails the activation. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(stirrup_agent): report the live turn of a run stopped around a compaction The previous commit kept no summary reply, but a run cut during a compaction still lost its last turn. Stirrup takes its history snapshot at the start of each turn and summarizes after the turn has answered. So during a summary request, the snapshot does not hold the turn that just ran, and the output was empty or ended with that turn's call without its answer. The runner now watches Stirrup's step, as it watches summarize_messages. It keeps the message list that step gets, which Stirrup extends with the answered turn, and keeps a reply only when its request is that list and only while step runs. On a cut, it reports that live list and the running turn's reply. A summary request sends a new list, so its reply is never kept. The test covers a cut after a summary, in the second summary attempt and in the first. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(stirrup_agent): answer a stop that ends the runner while it starts The runner installs its SIGTERM handler only after its imports. A rollout stop in that window ends the runner before it writes its report, and the activation still failed with "Stirrup sandbox runner exited without output". collect now also returns the empty stopped report when the session expired (a stop that the supervisor acted on) and the runner left no output file. A runner that crashed, or a deadline that ended it with no stop, still fails the activation. The report helper is now _stopped_without_output, since it covers both windows. Tests: a stop after the seed and before the run answers as an empty stopped run with no observation gaps. A runner that never gets past its start answers as an empty stopped run when a stop ended it, and fails when its deadline did. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * refactor(stirrup_agent): drop recover_from_context_overflow Stirrup reads this option only when the client raises ContextOverflowError, and the client raises it only with context_overflow_recovery on. With that option off, its default, Stirrup drops no turn whatever this option says. With it on and this option false, the episode ends at the first overflow, as it does with context_overflow_recovery off. So the option added no behavior, and a training config needs only context_summarization_cutoff: null. This removes the field, its payload key, the runner argument, its README row and paragraph, and its test cases. Draft #5835 adds the same option. No release has it, so no removed-option entry is needed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(stirrup_agent): bound context_summarization_cutoff at 1 Stirrup compares the cutoff with the last call's tokens divided by the context window, and it does not reject a value above 1. Such a value fires only when one call uses more tokens than the window. So a percent such as 70 turned compaction off with no error. The field now accepts values above 0 and at most 1, and null still never summarizes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * docs(stirrup_agent): name the other history rewrites, and fix the Stirrup config's network note The Stirrup README section on keeping the recorded history now also names truncation_recovery, which sends one call with an instruction that the history never records. It also names the two rewrites that stay: an assistant turn with no parsed tool call loses its tool-call text, and reasoning that comes back in its own field is not sent back. The header of officeenv_sandbox_stirrup.yaml said that Stirrup's sandboxes need the package index. The agent server builds Stirrup's Python runtime on its own host and uploads it, so the sandboxes need no internet. Only the host needs the package index. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * feat(single_agent_turn): drive the agent one step at a time and end the episode on the task state A resources server whose task ends through its state, rather than through one tool's call, can now have its episode end right after the step that ended the task. OfficeEnv's task ends when its user app's task row leaves pending, which several operations reach, depending on how a row exposes its apps. - single_agent_turn: max_episode_steps drives the agent one step per activation, up to that many steps, and end_on_task_state reads the resources session's task state between steps (GET /task_state, ResourcesTaskState in nemo_gym.server_runtime). Each step's failure report is kept. The server checks at startup that its agent keeps a session, runs the tools it calls and stops after one step. Driven episodes take part in checkpoints as restarts (BaseEnvironmentServer.checkpoint_mode_in_effect). - simple_agent: with x-ng-agent-episode-step-limit, a step stopped by its own one-step limit counts as completed unless it is the episode's last, and the session keeps one invocation for the episode, as the agent's own loop does, instead of one per step that repeats the whole history. - OfficeEnv: GET /task_state answers ResourcesTaskState; close_tools_on_task_end refuses the calls a step makes after the one that ended its task; its rows route by taskset to single_agent_turn with the step loop on, and the config allows only the simple agent. A retired attempt no longer keeps its episode, so its replacement can seed the same session ID. The server runs OfficeEnv 1.14.0 (1.13.0 at least), with its example rows emitted again. Signed-off-by: Daniele Molinari <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(single_agent_turn): run the step loop's tests in the core suite, and keep a simple_agent subclass in step CI on the step loop found two things: - agentic_turn_simulation_agent overrides simple_agent's _create_episode, which now takes step_limit_owned_by_caller. The override accepts it; only an agent session sets it, and this agent refuses those. - The core coverage gate counts single_agent_turn's and simple_agent's app.py, but the step loop's tests ran in the server suite only. They move to the core suite unchanged, and simple_agent's step limit and invocation folding get core tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(single_agent_turn): import each name in the moved step-loop tests from the module that defines it Tests under tests/ import from the defining module, not a package's public API, and test_the_librarys_tests_import_from_the_module_that_defines_each_name failed on the two files this PR moved into the core suite. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(simple_agent): one step per activation that names the episode's step limit, counted by its index With x-ng-agent-episode-step-limit, the agent takes one step (one model call and the tool calls it makes) whatever its max_steps says, so a pairing no longer needs max_steps: 1, which composition drops when --agent-type simple_agent replaces the environment's agent. Requests without the header run as before. - The step is the activation's index (x-ng-agent-activation), which such a caller sends with every step, not the count of requests, so a step resent after a dropped connection is not counted as the next one. - The session keeps the model server's cookies from step to step, so the episode keeps one model server session. - A step that raises ends the episode's folded invocation as failed (or incomplete when cancelled), not with the completed status of the step before. - The step keywords go to _create_episode only with the header, so an override that predates them keeps working; agentic_turn_simulation_agent's override no longer needs to accept one. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(single_agent_turn): drive only agents that take one step per activation, and keep what the steps did - STEP_DRIVEN_AGENT_TYPES (nemo_gym.config, beside AGENT_SESSION_AGENT_TYPES) lists the agent types that take one step per activation that names the episode's step limit: simple_agent. The startup check refuses any other type, such as hermes_agent or browsecomp_agent, which keep a session but run their own loop in an activation; a unit test keeps the list in step with the agent apps. The check no longer reads max_steps, and reads execute_tools as the agent's config does, so a string "false" is false. - A failure after a step completed keeps the completed steps, their output and summed usage, as its partial response, unless it already carries one; a failure before the first reply has none. - An episode that runs out of steps with every step calling a tool says so in its reply's metadata (ng_termination_reason: max_episode_steps). Its status stays the last step's: incomplete_details names only the model's own cutoffs, and an incomplete reply would read as malformed to rollout recovery. - The task state is not read after the last step, which ends the episode either way. - GET /task_state answering 404 with failure_kind session_lost ends the episode, which goes on to /verify and its masked lost-session result, as when a tool call finds the session gone. Other failed reads fail the episode as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(server_runtime): an environment server's checkpoint mode in effect sets its participant and its episodes A server whose class declares exported but whose instance runs as restart_only installs a restart_only participant, and its episodes begin as restarts; an unknown mode in effect stops the server at setup. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv): run on single_agent_turn_legacy, so flat rows and session-less agents run too single_agent_turn's /run takes only episode requests, so flat rows (training corpora, rows routed by their agent) failed. single_agent_turn_legacy takes flat rows and taskset episodes, and runs the same step loop: OfficeEnv keeps max_episode_steps 50, end_on_task_state, direct HTTP tools and the example taskset's route, and the simple agent no longer sets max_steps: 1. Composition's fallback relays an agent without agent sessions through legacy_agent to its own /run, so allowed_agents also admits simple_agent_with_compaction; the relay takes flat rows, not the taskset's episodes. The test that restated the YAML (skipped in CI with OfficeEnv absent) gives way to core tests that resolve the config with a model and build its environment server: as shipped, with simple_agent.yaml added as --agent-type simple_agent does, and with the compaction agent's config, where the server becomes a legacy_agent relay. The config comment and README say what --agent-type and allowed_agents do, and that rollout_recovery.target_level: sibling applies to the whole training run. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * docs: GET /task_state and the episode step-limit header The Seed/Verify Protocol Extensions table lists GET /task_state, its reply, and what a 404 or 5xx does to the episode. The agent integration page describes x-ng-agent-episode-step-limit beside x-ng-agent-activation. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(core): LentSandboxes lends a sandbox with its own image, environment and setup, and releases all within a deadline What the OfficeEnv sandboxed server needs from core's lent sandboxes, so it builds on them instead of a copy: - lend() takes a per-sandbox image, more environment variables and a setup that runs against the started sandbox, its files delivered, before it is lent (start_with_setup); a setup that fails stops the sandbox. - The start runs to its end once begun, within start_timeout_s (30 minutes by default), even while the request that asked for it is cancelled: a create cut in flight leaves a sandbox whose id the provider never returned. A lend cancelled meanwhile lends nothing and stops what it started, and says so in the log. - release_all(timeout_s=...) refuses new lends (503) from its start, waits for those still starting, stops everything within the deadline, and returns and logs the sessions whose sandbox may still run, for a reaper. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv): run OfficeEnv episodes in a sandbox, for Gym's sandboxed harnesses resources_servers/officeenv_sandbox's OfficeEnvSandboxResourcesServer subclasses the OfficeEnv server and lends each episode session a sandbox through LentSandboxes (an operate descriptor: the harness uses it, only the server stops it), stopped before the episode is graded. - The harness reaches the apps as the row's exposure says: MCP tools, a command per app (cli), or endpoints it finds over MCP and calls with curl (api_search). - File content stays out of the conversation through OfficeEnv's workspace mode: downloads land in the workspace, uploads and attachments name a workspace file, and a file API moves bytes directly. - The sandbox sees an ordinary company API. Only Gym's servers on this node (any of the node's own addresses) and trusted_networks reach seeding, closing, verification, metrics, the reverify mode, the app catalog, the task state and the tool routes, which answer others 404 before reading a body; sessions are signed with a per-process secret. - Seeds take turns, and a seed is admitted again before it lends; a close or a retire stops the sandbox, a failed seed's stop is tried again at its session's close, and shutdown stops everything within the run's grace. - A sandbox provider failure fails the call (502) and masks the episode's reward. - Configs for Pi (Docker and OpenSandbox), Codex CLI, mini-SWE, OpenCode, OpenClaw and Terminus 2; nine sandbox tasks (OfficeEnv 1.14.0), the first five as example rows with Pi's rollouts of them; images and a README. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(core): LentSandboxes logs a start its limit cut before the provider returned the sandbox's id When start_timeout_s cuts a provider's create in flight, the sandbox's id is unknown, so the lend's stop cannot reach what the create left. The lend now logs that cut at ERROR with the resources session, the task (id and taskset), the provider, the image and the labels, so a reaper can find the sandbox. A start cut after the create returned stops its sandbox as before and asks for no reaper. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * refactor(officeenv_sandbox): name each harness's instances after it, so harness configs compose in one run Every harness config defined `oe` and `single_agent_turn_legacy`, so two of them could not run together. Now: - the episodes' resources server is officeenv_sandbox_resources_server; - each config adds officeenv_sandbox_<harness>_agent (`_inherit_from` Gym's instance of the harness, as benchmarks do) and officeenv_sandbox_<harness>_environment_server (`_inherit_from: single_agent_turn_legacy`); - Pi, Codex and OpenCode, which name MCP tools their own way, run on their own copy of the episodes' server (officeenv_sandbox_<harness>_resources_server, `_copy` with its mcp_tool_prefix); the other harnesses run on the shared one. A copy takes the shared server's settings from the merged config, so one override reaches every harness. The interpolations, the documented overrides, the probe script and the README follow (a table of the names; the OpenSandbox config is listed after the other harness configs, since a later one pulls the episodes' config in again). A core test resolves each config alone and all six together with a model config, and replaces the server test that restated their YAML; it needs no OfficeEnv, so it runs in CI. The OpenCode and OpenClaw configs and the README no longer say those harnesses refuse MCP tool grants. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv_sandbox): sandbox_config.start_timeout_s bounds a sandbox's start; host_relay needs trusted_workstation - sandbox_config.start_timeout_s (1800 s by default, a finite number above 0) is passed to LentSandboxes, which fails the seed at that limit and logs a create it cut for a reaper. The README says when to raise it: creates on a busy OpenSandbox cell have taken up to 2,430 s. - host_relay forwards sandbox connections from the host's loopback, which the caller check takes for Gym's own servers, so code in a sandbox could call the routes kept for Gym for any session. Config validation now refuses host_relay unless sandbox_config.trusted_workstation is true, which a config sets only on a single-user workstation; its description and the README state the risk. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv_sandbox): officeenv_sandboxless.yaml runs the OfficeEnv server's instances under names of their own It composes resources_servers/officeenv/configs/officeenv.yaml and copies (`_copy`) its three instances as officeenv_sandboxless_resources_server, officeenv_sandbox_simple_agent and officeenv_sandbox_environment_server, each copy pointing at the other copies, while the OfficeEnv server's instances keep their names. The copied agent declares no dataset, so the example rows and their taskset stay with the OfficeEnv server's instances, and rows that name officeenv_sandbox_simple_agent (flat rows, agent_ref) route to the copied environment server. A `_copy` takes its source as written, before the source's own `_inherit_from` applies, so the environment server is copied as the instance of the server type officeenv_environment_server inherits, with that server's own settings for it on top. The core test checks each copy against its source, references aside, alone and beside the Pi and Codex configs, so a change to the source's server type fails it rather than leaving the copy behind. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv_sandbox): the sandboxless arm copies single_agent_turn_legacy, which the OfficeEnv server now runs officeenv_environment_server inherits single_agent_turn_legacy now, so the copy takes that instance, then the server's own settings for it under that type, with its references still pointing at the other copies. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * refactor(officeenv_sandbox): every harness runs the episodes' server under its own name, so none is left idle Each harness config now adds officeenv_sandbox_<harness>_resources_server with `_inherit_from: officeenv_sandbox_resources_server`, OpenClaw, mini-SWE and Terminus 2 included, and no harness names the episodes' server. `_inherit_from` reads it from the merged config and takes it out of the run, so a run of one or several harness configs starts no idle episodes' server, while the episodes config alone still runs it under its own name. Settings on the episodes' server, the OpenSandbox config's included, reach every harness's server. The OpenSandbox config still goes after the other harness configs (the first harness config listed pulls the episodes' config in), and the README now says why. The core test checks that no episodes' server starts or is named beside the harnesses', alone and with all six, and that the episodes config runs on its own. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(core): the cut-start log says OpenSandbox deletes what an abandoned create left Main's OpenSandbox provider now deletes the sandbox of a create its caller gave up on (#4799), so a start that LentSandboxes' start_timeout_s cuts before the provider returned the sandbox's id no longer needs a reaper there. The ERROR log, LentSandboxes' docstring and the officeenv_sandbox README now say so, and keep the reaper for providers without that cleanup. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv_sandbox): Pi's run ends once its task has ended, on every exposure - The sandboxed server holds the call that ends a watched episode's task, on every way in (tools, commands, endpoints, the file API), until the environment server releases it; the episode's lock is let go first. Only Gym's node reaches GET /task_state and POST /task_state/release. - Pi supports POST /rollouts/{rollout_id}/stop (_rollout_sandbox_session): a run stopped as completed answers so, marked in ng_rollout_stop, and is not reported as a wall-time timeout. - The Pi config sets end_on_task_state on its environment server and drops finish_tool_names (now []): the stop ends the run on cli and api_search rows too, which offer no finish tool. Its comment no longer asks cli rows to drop the MCP transport, which they run with as it is. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * docs(officeenv): the servers run OfficeEnv 1.14.2 1.14.2 is the OfficeEnv release N4's training runs grade with. 1.14.1 and 1.14.2 are patch releases; neither changes the API these servers use. The READMEs' install lines name it, and the example rows are emitted again by it (officeenv emit for resources_servers/officeenv, sandbox/prepare_rows.py for officeenv_sandbox), which changed only their version stamp. The example rollouts stay the ones collected against 1.14.0. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv_sandbox): refuse calls after the task ended with ResourcesSessionConflictError Main's session contract (#5691) has every 409 a resources server answers raise ResourcesSessionConflictError, and tests/unit_tests/test_session_contract_repo.py checks it. The sandboxed server refused a tool call once verification began, and a file API call once the episode's files closed, with plain HTTPException(409)s; both now raise the named error. The status and the detail are the same, so callers see no change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(core): LentSandboxes shields a start only with start_timeout_s Main's opencode_search (#6211) lends through LentSandboxes and expects a seed cancelled while its sandbox starts to stop that sandbox at once, as LentSandboxes did before this branch; the shielded start made it wait for the start's end. The shield is now opt-in. Without start_timeout_s a cancel cuts the start as it cuts any await, as on main, and the lend stops the sandbox it began. With it, the start runs to its end within that limit, which the OfficeEnv sandbox server sets (sandbox_config.start_timeout_s, 1,800 s by default). START_TIMEOUT_S goes, since no default limit remains. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * build(officeenv_sandbox): lock against main's upgraded dependency locks Main's lock upgrade (#6528) moved the root lock, and `uv sync --locked` refused the sandboxed server's older lock, so neither its suite nor a run could start it. `uv lock` with uv 0.13.4 takes the root lock's versions (e2b 2.50.0, protobuf-py 0.1.1, pyqwest 0.10.0), keeps the tzdata OfficeEnv pins (2026.6), and passes scripts/component_locks.py. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(core): a cut start's test counts the closes the provider made Main's #6410 changed the stopped fixture from AsyncSandbox.stop calls to the closes the provider made. A start cut before the provider returned its sandbox's id leaves nothing to close, so the hung-start test now expects none, as the ERROR line it checks says. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(single_agent_turn): stop an agent's own loop once its task has ended With end_on_task_state and no max_episode_steps, single_agent_turn now ends an agent that runs its own loop (a sandboxed harness) at its task's end, as the step loop ends a step-driven one: - Before the agent runs it reads GET /task_state?watch=true; while the agent runs it reads again, each read waiting up to 30 s (wait_s). - Once the task has ended it stops the run with POST /rollouts/{id}/stop {"reason": "task_ended", "completed": true}, waits for the activation to answer (at most 120 s), then posts /task_state/release. - The resources server holds its answer to the call that ended the task until that release, so the harness never reads it while its run could go on, and no model call follows the call that ended the task. - The server refuses at startup an agent type outside ROLLOUT_STOP_AGENT_TYPES (the agents whose runs the stop route can end; a unit test keeps the list in step with the apps). Core: RolloutStopRequest.completed; such a stop answers as completed (report_rollout_stop) and says so in ng_rollout_stop. Docker uploads take a bound of their own, so a stop's marker never waits for the exec slot a running harness holds (uploads_independent_of_execs). OfficeEnv: GET /task_state takes watch and wait_s (at most 60 s); POST /task_state/release; task_end_hold_seconds (180) bounds the hold. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(officeenv_sandbox): the stand-in sandbox stops as main's AsyncSandbox.stop does Main's #6410 moved the shielded, bounded stop into AsyncSandbox.stop(timeout_s=...), which LentSandboxes now calls. The tests' FakeSandbox.stop took no timeout_s and had no shield, so a seed or close cancelled during a stop failed or hung. FakeSandbox.stop now takes timeout_s and shields its provider-side _stop, as AsyncSandbox.stop does, and the tests that slow down, refuse or hang a stop patch _stop. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(cline_agent): the fake sandbox session carries expire_completed report_rollout_stop now reads SandboxSession.expire_completed (a run stopped once its task has ended answers as completed), so the stand-in that Cline's session tests use carries it too, as the real session does. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * refactor(officeenv_sandbox): sign sessions with Gym's run secret #6161 now makes a secret per server and run in server_runtime, which every worker of the server shares (signs_sessions_with_run_secret). The sandboxed server sets that flag instead of minting its own secret in model_post_init and overriding get_session_secret(): its cookies and MCP tokens are signed, as before, with a secret code in a sandbox cannot derive from the server's name. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv): refuse a tool call after the task ended with ResourcesSessionConflictError Main's session contract (#5691) has every 409 a resources server answers raise ResourcesSessionConflictError, and tests/unit_tests/test_session_contract_repo.py checks it. With close_tools_on_task_end, the OfficeEnv server refused a call after the task ended with a plain HTTPException(409); it now raises the named error. The status and the detail are the same, so callers see no change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * docs(officeenv_sandbox): say when the task-end stop ends a Stirrup run Stirrup cannot run without a finish tool, so with its default finish tool most runs end when the model calls finish. The environment server's task-end stop ends a run that calls `user complete-task`, before its next model call. Pi's config sets finish_tool_names: [], so for Pi the stop is the normal end. The README now says so. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(core): release_all stops the lent sandboxes while a lend is still starting release_all waited for every start in flight before it stopped any lent sandbox, all inside one time limit. One slow start at shutdown then left every lent sandbox running until its TTL. Now the lent sandboxes stop at once, and each starting sandbox is stopped when its start ends. The new test fails before this change (no sandbox stopped) and passes after it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(officeenv_sandbox): keep the agent and environment servers on 127.0.0.1 NeMo RL sets default_host to the node's address, and an explicit default_host applies to every server, not only to the types in absolute_ip_server_types. A sandbox's network rule opens every port of an allowed host. So code in a sandbox could call the agent and environment servers: run Pi on Gym's host (/v1/responses without a session), start episodes (/run) and stop another episode's run (/rollouts/{rollout_id}/stop). Each harness config now sets host: 127.0.0.1 on its agent and its environment server. No sandbox calls them: each harness in a sandbox calls only the model server and the resources server, and NeMo RL calls /run from the same node. Without default_host, Gym already binds them to 127.0.0.1. The comment in officeenv_opensandbox.yaml and the README now say this. The new config test resolves every harness config under default_host: 10.0.0…
mikemikimike
pushed a commit
to mikemikimike/Gym
that referenced
this pull request
Dec 1, 2026
…ic_turn_simulation judge (NVIDIA-NeMo#6320) * feat(agentic_turn_simulation_judge): add a resources server that trains the agentic_turn_simulation judge The policy plays the agentic_turn_simulation judge: each row holds the judge's exact prompt (rubrics, tool definitions, the recorded agent turn) and a reference label, and the policy writes the JSON verdict. The reward is 1 when the verdict's correctness ladder (`addresses_concern`, then `correct`) matches the label. Verdicts are parsed strictly and checked against the agentic_turn_simulation evaluation schema by default; a softer reward, a field bonus and an analysis word cap are optional. Metrics include accuracy, balanced accuracy, kappa, parse failures and the leniency gap, sliced by row provenance. Ships five synthetic example rows rendered with the agentic_turn_simulation judge prompt builder, hand-written example rollouts scored by the server, a row validator, and tests that check the verdict parser and ladder against the agentic_turn_simulation judge. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Junkeun Yi <[email protected]> * chore(agentic_turn_simulation_judge): set the config domain to agent Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Junkeun Yi <[email protected]> * fix(agentic_turn_simulation_judge): address review findings on ladder, field metrics and row validation - Ladder: `addresses_concern` must be "yes" before `correct` is read, so with `validate_schema: false` a verdict that never decides engagement (missing or invalid `addresses_concern`) gets no ladder and scores 0 (`missing_keys` / `bad_enum`). Schema-validated scoring (the default) is unchanged. - `field_acc/*`: a rollout without a prediction (unparsed, or no verifier output) counts as a miss for every known reference field instead of leaving the denominator. - `GoldFields` extras must be strings or null, matching the request model, so `validate_rows.py` rejects rows the server would reject. - `validate_rows.py`: files that share a basename are reported and split-checked by full path. - Test docstring: the committed example rollouts are hand-written, not a policy's outputs. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Junkeun Yi <[email protected]> * revert(agentic_turn_simulation_judge): keep the ladder rule for schema-disabled scoring `validate_schema` is on by default and then every schema field must be valid. With it off, only the ladder is read, as before: `addresses_concern` "no" gives "no", otherwise `correct` decides. Reverts the `correct_ladder` / error-classification change and its tests from 87c4277; the other fixes stay. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Junkeun Yi <[email protected]> * fix(agentic_turn_simulation_judge): address review on lock, verify errors and parser speed - Refresh uv.lock for current main (root pins moved in NVIDIA-NeMo#6528 and after). - Mask a verifier exception (mask_sample, failure_kind verifier_error) instead of scoring it 0; read_verdict no longer turns parser exceptions into bad_json. - pred_fields returns strings only, with lone surrogates replaced, so /verify never answers 500. - Remove reward_mode soft (unused); the reward is the gold_ladder match. gold_p_yes is provenance. - Strip the strict-mode fence by slicing and run the think regex only up to the last closing tag (both were quadratic on adversarial text; same results). - Name the ATS source file and commit of the copied code; add a RunRequest/TaskData drift test. - README: how labels are built, what each parse_error code covers. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Junkeun Yi <[email protected]> * fix(agentic_turn_simulation_judge): import VERIFIER_ERROR from the public nemo_gym.core API Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Junkeun Yi <[email protected]> --------- Signed-off-by: Junkeun Yi <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
#4837 gave every managed project its own
uv.lock. Those locks kept the package versions in the rootuv.lock, which had not been upgraded since the repository was imported in September 2025. Before #4837, server environments installed without pins and got current releases. After it, about half of the locked packages moved back to older versions.NeMo RL found one effect after bumping Gym in NVIDIA-NeMo/RL#5195.
workplace_assistantdoes heavy single-threaded pandas work on every rollout. Its lock pinned pandas 2.3.2 instead of 3.1.x, which made the environment about 20% slower and made it the bottleneck in a 1,024-concurrency GRPO run. Changing only the pandas version brought the run back to its earlier speed. Nothing caps pandas below 3. A cleanuv lockresolves 3.1.1.This PR:
--upgradetoscripts/component_locks.py, which runsuv lock --upgradefor every managed project, so a scheduled lock refresh can use the same commandray[default]<2.60: Ray Serve 2.60 importsgrpc_reflectionwithout declaring it. Declaringgrpcio-reflectionhere, as Gym already does forjinja2, needs protobuf 7, which conflicts with vLLM'sprotobuf<7.e2b<2.51.0: 2.51 stopped defaultingpause()to keep memory, and 2.52 removedclient_async.get_envd_transport, which the e2b provider replaces. The install hint, config comment and README now name the new range.mcp>=1.28.1,<3, and its code works on MCP 2 after #4567. These tests readstructuredContentandisErroras attributes and usedstreamablehttp_client. They now read wire field names frommodel_dump(by_alias=True)and usestreamable_http_client, which both versions support.Notable version changes
pandas reaches 3.1.1 in almost every lock. Major-version moves in the root lock:
Server request-path packages also move, for example:
protobuf stays at 6.33.6 in the root lock because of vLLM, and moves to 7.36.2 in most component locks.
For the environment locks, these are mostly the versions their unpinned installs used before #4837. For the root lock, which the Docker image and CI install from, they are new.
Compatibility
rayande2branges. Users already on ray 2.60 or e2b 2.51 and later get an older version on their next resolve.Issue
No issue was filed. NeMo RL reported the regression directly, and this PR is the fix.
Validation
python scripts/component_locks.py --upgrade --jobs 16, thenpython scripts/component_locks.py --jobs 16: every managed project resolves and passes the lock checkpre-commit run --files <changed files>: passedmain:mainon this workstation.main, except one checkpoint worker test that is timing-sensitive under parallel load and passes when run on its own.Rollout evidence
grpo-qwen3-0.6b-1n8g-megatron-vllm-tp2-single-controller-gym-api8returned to its pre-regression speed.