Skip to content

feat(video_mcqa): a shared video multiple-choice base: judge-read answers from each row's question, question sets, frame rows - #6238

Closed
cg1177 wants to merge 6 commits into
NVIDIA-NeMo:mainfrom
cg1177:guoc/video-mcqa-llm-extract
Closed

cg1177 wants to merge 6 commits into
NVIDIA-NeMo:mainfrom
cg1177:guoc/video-mcqa-llm-extract

Conversation

@cg1177

@cg1177 cg1177 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Makes resources_servers/video_mcqa the shared base for video multiple-choice questions. The Video-MME v2, Video-MME
and LVBench servers (#6071), and any other question set, such as a training set, fill it with data and configuration;
the base has no benchmark- or training-specific path.

  • Each row keeps its question. verifier_metadata gains question (the question text) and options (the option
    texts in label order, without labels), next to expected_answer and option_count. VerifierMetadata and the
    task-data schemas require both; prepare_single_turn, prepare_agentic and prepare.py write them from the
    annotation.
  • Answers read by a judge model (llm_extraction_v1, opt-in). The rule policies from feat(video): add single-turn Video-MME v2, Video-MME and LVBench environments #6071 read a boxed letter
    (boxed_only_v1, the default) or an answer that is exactly one letter (boxed_or_letter_v1). The benchmarks' own
    prompts ask for the bare letter, and models answer them in free form (Answer: A, (B), **C**, a sentence that
    ends in the letter), which the rule policies reject by design. Under llm_extraction_v1 a judge model reports which
    option the final answer gives, and the verifier scores that option against the gold label.
    • The judge is any OpenAI-compatible chat model behind a Gym model server (judge_model_server, called through
      call_judge on /v1/chat/completions with judge_chat_completion_create_params). Its one user message
      (LLM_EXTRACTION_PROMPT) holds the row's question, its options as A. ... lines, and the final answer
      without its reasoning. It never reads the model's request, so the video, its frames and whatever else the prompt
      holds never reach it; it never gets the gold label, is told not to decide which option is correct, and replies
      {"choice": "<letter or none>"}.
    • none (no option, several, or unclear) is the new outcome no_choice, a measured zero. An empty final answer
      stays no_answer and is not sent. Failed model calls, single-turn tool calls and failed agent runs are
      classified before any judge call.
    • A failed judge call, or a reply without a usable choice, is not a wrong answer: Gym's judge failsafe masks the row
      (failure_kind: judge_failed) and keeps it with its answer in the failures file, and the frozen cohort counts the
      task as missing until gym eval reverify --judge-failed-only or a resume judges it again. The judged grading runs
      in observe_llm_judge_grading, so Gym binds the graded response and reward to the judge's reply.
    • The cohort declares the policy (prepare.py --answer-policy llm_extraction_v1); a server whose cohort uses it
      refuses to start without judge_model_server. The rule policies stay the default and never call a judge, so CI
      and the committed examples need no key. videomme_v2 uses the same judge path.
    • prepare_single_turn(..., prompt=...) and prepare.py --prompt take boxed (default, unchanged) or a
      benchmark's bare-letter prompt: videomme_v1 (the Video-MME README's prompt), videomme_v2 (the official
      script's letter instruction, in the form NVIDIA's evaluations use) and lvbench (LVBench publishes no prompt; the
      common LLaVA-style instruction). The README lists the texts and sources.
    • Configs: <benchmark>_single_turn_llm_extraction.yaml for the three benchmarks, and
      video_mcqa_single_turn_llm_extraction.yaml for the shared verifier: the single-turn config plus an
      openai_model judge (judge_base_url, judge_api_key, judge_model_name).
  • Question sets. A cohort may be a question set instead of a benchmark (question_set.py, QuestionSetCohort):
    a name, the source and a 40-character revision of the set, the setting, the answer policy and the task IDs. Its
    questions take 2 to 26 options and no level or group, its task IDs never use a benchmark's scope (videomme_v1:,
    lvbench:), and its accuracy is reported under its own name, without categories. A training set runs on the shared
    verifier this way, with the same configs; the README shows a NeMo RL configuration. The VideoMME-v1 and LVBench
    servers refuse a question set.
  • A video as labelled frames. prepare_single_turn(..., frames=[(label, image_url), ...]) (and
    task.video_parts) send the video as frames sampled ahead of time: each frame is its label as an input_text part
    followed by the frame as an input_image part, and the question comes last.
  • empty_answer_reward (resources server option, unset by default, which scores 0): the reward of an attempt
    that produced output but no final answer (reasoning only, an unfinished reasoning block, an empty message), for
    example a training penalty. A response without any output stays 0, as Gym's agents require for a failed run, and
    accuracy counts the attempt as no_answer either way.
  • Benchmarks adapt to the base. The shared rows take 2 to 26 options; four choices is now VideoMME-v1's and
    LVBench's own rule, in their task_data.py. Video-MME v2 keeps its grouped and level scoring in its own server.

Rows without question and options are refused, not judged from the request: one path for the judge's input, and
nothing for a prompt's format to break (a row's prompt may hold frames, frame labels or a sandbox path). Every
preparation path in the repo writes the fields, so older rows only need preparing again.

Provenance: the judge's instructions (LLM_EXTRACTION_PROMPT) and its reply rules (the first-to-last-brace JSON
object, "none" in any case, a letter of the question in any case) are ported from NVIDIA's internal evaluation code
(same copyright holder, Apache-2.0); the judge here sees the row's question and options in place of the prompt text.
The Gym code around them (policy, outcomes, failure routing, question sets, frames, configs, prompt styles) is new.

No issue: a focused follow-up to #6071. #6314 (video_qa_rubric) is independent of this PR; see Merge order.

Validation

At the head (1e1e48be3459b224bbf9c2b1f3f59526a74d7c2a, with main eff187554 merged in):

  • gym env test +entrypoint=resources_servers/<server> +should_validate_data=true (FFmpeg 7.0.2 on PATH):
    video_mcqa 353 passed and 122 subtests, videomme_v2 136, videomme_v1 1, lvbench 1; the data of all four
    validated. New and updated tests: the judge prompt built from question and options only (the same for a video
    row and a frames row; a changed request does not change it; no frame, label, URL or prompt instruction in it), a row
    without the fields refused at /verify (422) and by every schema, question-set cohorts (scoping, frozen IDs, metrics
    under the set's name, other option counts), frames rows, empty_answer_reward (only no_answer with output; a
    failed agent run stays 0; accuracy reads the outcome), the reply parsing, judge_failed routing, the grading record,
    the start-up check, the four configs and the letter prompts.
  • pre-commit run --all-files: pass, no changes. scripts/component_locks.py: 321 projects, 0 failed. CI's
    secrets-detector command on the 34 changed files: exit 0. The core tests of these schemas
    (tests/unit_tests/data/test_task_data.py, tests/unit_tests/benchmarks/test_video_mcqa_task_data.py): 522 passed.
  • scripts/ci/core_unit_tests.sh (unsharded), at this PR's commit 83bebc7ab on main 46683f974 (the later merge of
    main changes none of this PR's files): 23,113 passed, 108 skipped, 341 subtests. Two subtests of
    tests/unit_tests/benchmarks/test_super_vllm_launcher.py (SIGINT shutdown, "Launcher did not terminate") failed
    while a second suite ran on the machine; the file alone passes (52 passed, 319 subtests), and nothing it covers is
    touched here.
  • Real annotations, single-turn preparation: the 3,200 Video-MME v2 questions through prepare_single_turn(prompt= "videomme_v2") and the 2,700 Video-MME questions through prepare.py --prompt videomme_v1 --answer-policy llm_extraction_v1 (official annotations at the pinned revisions; the videos' SHA-256 from their listing, no video
    read): every row carries question and options, both appear in its prompt, and the server's VerifierMetadata
    accepts it.
  • The committed example rows and rollouts of the four servers gain the two fields, rebuilt with
    prepare_single_turn from the same questions; nothing else in them changes.
  • Live judge check (gpt-6.1-sol, reasoning effort max, through Gym's openai_model server code; a CPU job): 18
    calls, all HTTP 200 on the first attempt, about $0.04 in all. The multiple-choice part, 10 calls: three rows of a
    training question set (frames as images, a question-set cohort on the shared verifier) and two Video-MME v2 agentic
    rows (the videomme_v2 server), each with the gold option named in prose and a wrong option boxed. All 10 were
    read and scored as expected (correct / incorrect), every reply a JSON choice. No judge prompt held a frame
    label, a file URL or a sandbox path; each held its row's question and every option line. (The other 8 calls
    graded open-ended answers for feat(video-qa-rubric): open-ended video QA graded against each question's rubric #6314 and feat(video): agentic Video-MME v2, Video-MME, LVBench and open-ended video QA on stock opencode_agent, with Video-MME v2 / Video-MME agentic benchmarks #6315.)

Before this change, with the judge reading the request's text: all tests of the four servers (434), the core suite,
a local pipeline smoke with an OpenAI-compatible stub (judge failures masked and judged again), and 551 saved answers
of an internal evaluation of a Nemotron model (Video-MME v2, Video-MME and LVBench, single-turn and agentic) read the
same as by our earlier judge setup, 551/551 on the first attempt. That comparison used the request's text as the
question; the live check above covers the question taken from the row.

Rollouts

The policy-side behavior is unchanged except for the optional letter prompts and the frames layout, which the tests
cover; no new example rollouts. The live judge check above uses scripted answers.

Compatibility and benchmark impact

  • Rows need question and options. Rows prepared with feat(video): add single-turn Video-MME v2, Video-MME and LVBench environments #6071's code lack them and are refused (by the task-data
    validation and at /verify); prepare them again with this version. The committed examples are migrated.
  • The shared video_mcqa rows accept 2 to 26 options; the VideoMME-v1 and LVBench schemas and servers still require
    four.
  • grade_final_answer no longer takes the request; scoring.prompt_text is gone (neither is on main).
  • New public names: AnswerPolicy value llm_extraction_v1, outcome no_choice, PromptStyle, the prompt and
    frames arguments of prepare_single_turn, task.video_parts, InputImage, prepare.py --prompt,
    question_set.QuestionSetCohort, and the resources-server fields judge_model_server,
    judge_chat_completion_create_params and empty_answer_reward. Default policy, prompts, configs, outcomes and
    metrics are unchanged. llm_extraction_v1 scores depend on the judge model, so report it with the score; they are
    not comparable with rule-policy scores.

Merge order

#6314 (video_qa_rubric) is independent. Both rename video_mcqa.scoring._final_text to final_answer_text the
same way, so that file merges cleanly in either order; the only conflict, in either order, is two neighboring rows of
the root README's environment table (keep both, or rerun the update-readme-table hook). #6315 (agentic video) is
stacked on this PR, #6290 and #6314.

Checklist

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

Generated with Claude Code

… 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]>
@copy-pr-bot

copy-pr-bot Bot commented Nov 16, 2026

Copy link
Copy Markdown

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

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added feature New capabilities, enhancements, or enablement work area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers needs-review PR is ready for code review and waiting on a reviewer labels Nov 16, 2026
@cg1177

cg1177 commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

@cmunley1 could you trigger CI on this PR when you have a moment? The command is /ok to test 4a24800.

@yfw could you review it? It adds opt-in judge-model answer extraction (llm_extraction_v1) to the Video-MME v2 / Video-MME / LVBench environments from #6071, so runs that use the benchmarks' own letter prompts get scored the same way as our internal evals. The rule parsers stay the default, so CI and the examples need no API key. Thanks!

cg1177 added a commit to cg1177/Gym that referenced this pull request Nov 17, 2026
…ames

Brings in NVIDIA-NeMo#6238: a judge model can read the chosen option (llm_extraction_v1),
which the agentic benchmarks use with the benchmarks' own letter prompts.

Conflicts in resources_servers/video_mcqa/app.py and videomme_v2/app.py:
verify keeps this branch's response_failure (an agentic outcome read from the
response's own status) and the lent-sandbox server and config bases, and takes
NVIDIA-NeMo#6238's AnswerJudgeConfig and grade_final_answer.

Signed-off-by: Guo Chen <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the sla:triage-overdue Review assignment is over the one-business-day SLA label Nov 17, 2026
cg1177 and others added 3 commits November 18, 2026 02:31
Signed-off-by: Guo Chen <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… 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]>
Signed-off-by: Guo Chen <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cg1177 cg1177 changed the title feat(video): optional judge-model answer extraction for Video-MME v2,… feat(video_mcqa): a shared video multiple-choice base: judge-read answers from each row's question, question sets, frame rows Nov 18, 2026
cg1177 added a commit to cg1177/Gym that referenced this pull request Nov 18, 2026
…ames

Brings in NVIDIA-NeMo#6238's new head: video_mcqa as the shared base. Each row keeps its
question and options for the answer judge, a cohort may be a question set, a
video may come as labelled frames, and empty_answer_reward is optional.

Conflicts: the video_mcqa/app.py docstring and imports (both sides kept: the
question-set cohort and this branch's lent sandbox); prepare_agentic keeps this
branch's letter prompts and writes the row's metadata the shared way; the
task_data.py docstring; the root README rows (both sides' rows).

Signed-off-by: Guo Chen <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
cg1177 added a commit to cg1177/Gym that referenced this pull request Nov 18, 2026
…ptions

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]>
cg1177 added a commit to cg1177/Gym that referenced this pull request Nov 18, 2026
…ames

Brings in NVIDIA-NeMo#6238's pushed head, which merged main eff1875 into it.

Signed-off-by: Guo Chen <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@yaoyu-33 yaoyu-33 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two scoring cases to address before merging.

Comment thread resources_servers/video_mcqa/task.py Outdated
video_source: str
video_sha256: str
question: str
options: tuple[str, ...]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could aggregation still accept saved rule-scored rollouts without question and options? Reaggregating an existing boxed_only_v1 result now raises TypeError, and preparing the input again doesn’t update that saved result.

Comment thread resources_servers/video_mcqa/scoring.py Outdated
verdict = None
if not isinstance(verdict, dict):
raise ValueError(f"The judge's reply has no JSON object: {text[:300]!r}")
choice = str(verdict.get("choice", "")).strip()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A judge reply of {"choice": null} becomes the string "None" here and counts as a measured zero. Could we require a string before normalizing it so malformed replies follow the judge-failure path?

@github-actions github-actions Bot removed the sla:triage-overdue Review assignment is over the one-business-day SLA label Nov 19, 2026
…n-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]>
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the risk:high Autobot PR risk: high label Nov 19, 2026
@cg1177

cg1177 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! Fixed both in ed47957: question/options are optional again (both or neither), so saved boxed_only_v1 results aggregate and replay like before, and only llm_extraction_v1 refuses a row without them. A non-string choice like {"choice": null} now counts as an unusable reply, so it takes the judge-failure path (masked, kept for rejudging) instead of scoring zero. Added tests for both. Could you /ok to test ed47957?

yaoyu-33
yaoyu-33 previously approved these changes Nov 20, 2026

@yaoyu-33 yaoyu-33 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated parser handles malformed judge choices, and saved rule-scored results still aggregate. LGTM.

@yaoyu-33 yaoyu-33 added ready-to-merge PR is approved, current, and waiting for final CI or merge and removed needs-review PR is ready for code review and waiting on a reviewer labels Nov 20, 2026
@cg1177

cg1177 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test ed47957

@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 20, 2026 23:22
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]>
@svcnvidia-nemo-ci svcnvidia-nemo-ci added risk:low Autobot PR risk: low and removed risk:high Autobot PR risk: high labels Nov 21, 2026
@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

/ok to test 661b052

@cg1177

cg1177 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

This landed in main as part of #6315, closing.

@cg1177 cg1177 closed this Nov 21, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers feature New capabilities, enhancements, or enablement work ready-to-merge PR is approved, current, and waiting for final CI or merge risk:low Autobot PR risk: low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants