Skip to content

feat(visual_coding_opencode): visual-coding environment and BabyVision on OpenCode sandbox sessions - #5839

Merged
yfw merged 18 commits into
mainfrom
yifuw/babyvision-opencode-sessions-main
Nov 11, 2026
Merged

yfw merged 18 commits into
mainfrom
yifuw/babyvision-opencode-sessions-main

Conversation

@yfw

@yfw yfw commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

What this is

A multi-turn visual-coding environment, visual_coding_opencode, with the BabyVision benchmark (388 visual-reasoning puzzles) and its question-only variant. OpenCode answers a question about an image in a sandbox whose shell has Python with pillow, numpy, scipy and opencv, so the model can crop, measure and plot the image. A GPT judge grades the final \boxed{} answer against the gold answer.

Each task runs as an opencode_agent sandbox session behind the single_agent_turn_legacy Environment Server:

  • The resources server lends each episode a sandbox through LentSandboxes, with sandbox_network_access: model_only: the sandbox reaches only the policy model server's host, on every port, so the model cannot look answers up (blocking raw IPs needs an OpenSandbox server with dns+nft). Every other Gym server in this config (the judge, the agent, the resources and Environment Servers) sets host 127.0.0.1, so sandbox code cannot reach them, also under NeMo RL's default_host. One limit: under NeMo RL, Gym's head server takes the node address, which is the policy host, so the sandbox can reach it and its /global_config_dict_yaml (the merged config, including any key passed literally). Other environments' servers in an RL blend that do not set 127.0.0.1 get the node address too. Allowing only the model server's port needs a change in core. The close stops the sandbox. The sandbox image carries the toolkit, OpenCode 1.17.11 and OpenCode's plugin dependencies, each pinned by SHA-256 and checked when the image builds.
  • The prompt image is attached with opencode run --file, and the agent sets image_input: true, so OpenCode's read tool also returns the model's crops and plots as images. Compaction is off, so Gym's token capture joins every model call, and the same config serves evaluation and RL training. There is no step limit.
  • The judge grades the last \boxed{} and the end of the model's text. Only the judge's own verdict, the last one in its reply, counts, and the judge prompt marks the model's text as data. A run that does not complete scores 0 without a judge call: an incomplete run (a timeout, an output cap or a context limit), or a failed run that the outcome policy still sends to verify. A judge failure (a failed call, or a reply without a valid verdict) is masked as judge_failed, not scored 0.
  • The Environment Server admits 64 episodes at a time, the agent's concurrency, because each seed starts a sandbox. The server refuses num_workers > 1 before launch, because lent sandboxes live in one worker's memory.
  • The pairing is OpenCode-only: the instruction names OpenCode's tools, and the sandbox image ships only OpenCode. A Pi pairing is a follow-up.

The PR also adds the "Evaluate Visual Coding with OpenCode" tutorial, the BabyVision prepare scripts, and five example rows with their metrics and rollouts. prepare.py downloads the public UnipatAI/BabyVision release (MIT license) at a pinned revision and checks its SHA-256; that commit is Danial's from #5915. Two of the example rows are BabyVision tasks from the same release.

Issue

No linked issue: this continues #5712 and #5814 (below).

Relation to other PRs

Compatibility and benchmark impact

A new environment and two new benchmarks. No existing config, benchmark or result changes, and no file outside this environment changes. An earlier version of this PR changed agentic_if_realworld's resume fingerprint; main's #5909 fixed that cause, so the PR no longer touches that folder. There is no full 388-row baseline yet.

Validation

  • At 8c39ca8 (main merged on 11-10): the environment's tests (57: judge, grading record, close order, lent sandbox, seeds, session contract, the example rows in an opencode_agent session, verifier fixture), opencode_agent (904, 23 skipped), and the unit tests for the BabyVision configs and prepare, docs links, the public API and the README table (1020) pass. pre-commit passes. CI passed at 8a39cda; after it, the branch adds only the merge with main and the regenerated example rollouts.
  • Eval smoke at 8a39cda with a rebuilt sandbox image, 5 example rows x 2: all 10 runs ended and none was masked. 8 scored 1.0. The 3D cube-counting row did not complete either time, so it scored 0 without a judge call. OpenCode's first model call came 1.08 s (median) after its session started. From inside a lent sandbox, all 7 network checks gave the expected result: internet hosts did not resolve, the policy model answered, and the judge, agent, resources server and Environment Server ports refused connections.
  • Example rollouts, collected at the same commit (one run of each row): all 5 completed and 4 are correct; the cube row answered 20 where 19 is right.
  • Sandbox image: it builds, the plugin-dependency archive and the OpenCode binary match their pins, and offline OpenCode reaches its first model call in 1 s with the archive (71 s without it).
  • gym env test +entrypoint=resources_servers/visual_coding_opencode +should_validate_data=true: the data validates.

Earlier runs, before the review fixes of 11-10:

  • Eval retest at e461ff2 with a rebuilt sandbox image, 5 example rows x 2: 10/10 completed, 8 correct, none masked; the 3D cube-counting row failed both times. OpenCode's first model call came 1.2 s (median) after its session started. From inside a lent sandbox, internet hosts did not resolve, the policy model answered, and the judge, agent, resources server and Environment Server ports refused connections.
  • Eval smoke (OpenSandbox, a hosted vision-language policy through Gym's model server, a gpt-4o-mini judge): 3 example rows x 2 repeats, all 6 completed and scored 1.0.
  • RL smoke with token capture (NeMo RL single-controller GRPO, a vision-language policy, 16 prompts x 8 rollouts, 3 steps, score centering on, BabyVision rows, lent model-only sandboxes):
Step Train reward Calls per rollout Poisoned rollouts Masked sequences
1 0.462 15.2 0 9 (overlong)
2 0.565 13.4 0 4 (3 overlong, 1 logprob error)
3 0.398 11.9 0 5 (4 overlong, 1 logprob error)

All 128 rollouts of each step were graded, every training row carried its images, and the generation KL error stayed near 0.004. No sandbox stop failed. A few sandboxes went away mid-episode (HTTP 410 to the agent); no rollout was dropped for it.

🤖 Generated with Claude Code

@copy-pr-bot

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

@yfw yfw added area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers feature New capabilities, enhancements, or enablement work labels Nov 9, 2026
@yfw

yfw commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 75fe2bc

@yfw

yfw commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 1a81487

@yfw

yfw commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 5a53776

@copy-pr-bot

copy-pr-bot Bot commented Nov 9, 2026

Copy link
Copy Markdown

/ok to test 1a81487

@yfw, there was an error processing your request: E2

See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/2/

@copy-pr-bot

copy-pr-bot Bot commented Nov 9, 2026

Copy link
Copy Markdown

/ok to test 75fe2bc

@yfw, there was an error processing your request: E2

See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/2/

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

@yfw
yfw force-pushed the yifuw/multi-harness-core branch from 728cae8 to 1686209 Compare November 9, 2026 18:53
@yfw
yfw force-pushed the yifuw/babyvision-opencode-sessions-main branch from 5a53776 to 500a95c Compare November 9, 2026 18:57
@yfw

yfw commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 500a95c

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

HOLD

The sandbox can reach the credential-backed judge, which violates the intended policy-only boundary. I also found four reliability defects and two documentation issues, detailed inline.

I assessed all 34 changed files and their directly affected contracts. I covered grading and data/docs directly where delegated reports weren't available. This was static review: I didn't run tests, build the image, decode the example images, or reproduce the reported evaluation and RL smokes.

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

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

@yfw
yfw force-pushed the yifuw/multi-harness-core branch from 1686209 to f97a6ac Compare November 10, 2026 00:44
@yfw
yfw requested a review from a team as a code owner November 10, 2026 00:44
@yfw
yfw force-pushed the yifuw/babyvision-opencode-sessions-main branch from 500a95c to 9af1da9 Compare November 10, 2026 00:44
@yfw

yfw commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 9af1da9

@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 10, 2026 00:45
@yaoyu-33
yaoyu-33 added this pull request to the merge queue Nov 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 10, 2026
Main 5365700. One conflict, in the README environment table: main's #5819
renamed the second Vibench row to vibench_legacy_agent.yaml. Kept main's rows
and this PR's Visual Coding Opencode row; scripts/update_env_list.py gives the
same table.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
@yfw

yfw commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test e1ee213

…head

One OpenCode rollout of each of the 5 example rows, collected at 8a39cda.
All 5 runs complete; 4 are correct, and the 3D cube-counting row answers 20
where 19 is right (judge: different, reward 0). The prompt image is attached
to the first message, so no row reads the old input-media/None path. The rows
carry task_id and no longer carry string_match_reward.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
@yfw

yfw commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 8c39ca8

yaoyu-33
yaoyu-33 previously approved these changes Nov 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

yfw and others added 2 commits November 10, 2026 16:27
Main 7bceb31. No conflicts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
Main's #5464 moved the shared openai pin to 2.45.0 and relocked every
component on main. This component was not on main yet, so its lock still had
2.44.0, and both the component-lock check and the server suite's
`uv sync --locked` failed in the merge queue. Regenerated with
scripts/component_locks.py (check_project, update=True); the only change is
openai 2.44.0 -> 2.45.0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
@yfw

yfw commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 5919a29

@github-actions

Copy link
Copy Markdown
Contributor

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

This branch had an error being deployed

1 failed deployment
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants