Repository navigation
Conversation
…te /tmp Opt-in options for multimodal tasks: - attach_images writes the data-URL images of the last user message into the run dir as image_<i>.<ext> and attaches them with -f. - vision declares the generated model_server entry image-capable, so OpenCode sends the attachments and its read tool returns image files as images. - private_tmp runs OpenCode in a user+mount namespace whose /tmp is the run's own, with the host /tmp entries the run needs (Gym, venvs, OpenCode) bound back. Models write scratch files to fixed /tmp names that concurrent runs would otherwise share. OpenCode's config/cache/state dirs move into the run dir with its data dir (read-only $HOME clusters), and the Node.js download matches the host architecture (aarch64). Signed-off-by: smohsenitahe <[email protected]>
opencode_agent in a server venv that also carries pillow, numpy, scipy and opencv (overrides.txt re-enables opencv-python-headless). OpenCode's bash tool inherits the server environment, so the model's python3 can crop, measure and plot task images. Signed-off-by: smohsenitahe <[email protected]>
… judge BabyVision (388 rows) as Python_call_gen's opencode harness runs it: the same prompt (instruction, ---, question, boxed suffix), the image attached and in the run dir, OpenCode 1.17.11 tools with a Python image toolkit, 1800 s per task, no turn cap, private /tmp. The reward is the gpt-4o-mini verdict with format_judge's correctness prompt (equivalent = 1; different, unsure, judge error and empty response = 0); string_match's grade is kept as a diagnostic. prepare.py reads $LMUData/BabyVision.tsv. Signed-off-by: smohsenitahe <[email protected]>
…yvision_opencode)
The resources server never depended on BabyVision: it GPT-judges the final \boxed{}
answer of an OpenCode + Python-image-toolkit run. Rename it to visual_coding_opencode,
move the judge model server into its config, and keep BabyVision as a benchmark config
on top of it. Training sets (e.g. visual-tracking puzzles) use the same row format.
Signed-off-by: smohsenitahe <[email protected]>
OpenCode drops the token IDs and logprobs the Gym model server returns and re-renders history as text, so its rollouts could not be trained on. With track_token_ids the agent serves OpenCode's chat-completions endpoint itself: each call is forwarded to the policy with the producing call's token bundle re-attached to the last assistant message (the NeMo RL vLLM server pins the prompt prefix to it), and the returned bundle is recorded and stripped. The rollout output is the deepest chain of calls: per call, the images it newly saw, the assistant message with its tokens, and its function calls. Signed-off-by: smohsenitahe <[email protected]>
Optional generation_topk_token_ids / generation_topk_log_probs ([tokens][k]) on the token bundle, passed through by vllm_model and kept on opencode_agent's tracked rollout output (never re-sent to the policy in later requests). Used for score centering in RL. Signed-off-by: smohsenitahe <[email protected]>
Programs the model starts from OpenCode's bash tool (python scripts, background jobs) outlived the run when only OpenCode was killed, accumulating until the host ran out of memory (an RL run's Gym node reached 875/900 GB and lost its vLLM worker and Gym actor). OpenCode now runs in its own session and the group is SIGKILLed on timeout and on exit. Signed-off-by: smohsenitahe <[email protected]>
…Ray nodes All sessions ran as subprocesses of the agent server, so one host's CPUs and RAM (~0.9 GB per OpenCode process plus the model's Python tools) capped the session count; in an RL run with 24 vLLM nodes, those ran at ~28% GPU utilization. With session_nodes=N each session is a Ray task pinned round-robin to one of N nodes (this server's first): it recreates the run dir there (node-local workspace_root), runs OpenCode in its own process group, and returns only the OpenCode session database, which the agent parses as before. Token tracking is unchanged: remote OpenCode calls the agent's proxy over HTTP. Signed-off-by: smohsenitahe <[email protected]>
… the policy OpenCode's interleaved-reasoning config sends each assistant turn's reasoning back in a "reasoning" key. The policy server's chat-completions request model now forbids unknown message keys (extra="forbid"), so every multi-turn track_token_ids request after the first failed with 422 and OpenCode exited. The re-attached token bundle already carries that turn's tokens. OpenCode now replays reasoning as reasoning_content by default (Gym #4180), which the request model accepts; it is dropped too, so the proxied request renders as before. Signed-off-by: smohsenitahe <[email protected]>
…(session_sandbox) Port of the session_sandbox backend from the Gym-rl-opencode fork. With session_sandbox set, each OpenCode session runs in its own sandbox from a nemo_gym.sandbox provider (e.g. OpenSandbox) instead of on the agent's host: the run dir is uploaded, OpenCode runs there and calls the model through this agent as usual, the session database is downloaded back and the sandbox is deleted. A sandbox failure is reported like a failed OpenCode run, not raised. - provider_secret_env reads provider credentials from the environment, so they never appear in configs or logs and never reach a sandbox - ca_file trusts a provider server's self-signed certificate - max_concurrent_starts bounds simultaneous sandbox creates - session_exclude_actor_classes keeps sessions off nodes running given Ray actor classes (e.g. RL training nodes) when session_nodes > 1 Signed-off-by: smohsenitahe <[email protected]>
…t venv session_sandbox needs Gym's `sandbox` extra (opensandbox, tenacity, httpx-aiohttp), which the agent's requirements did not pull in: a rebuilt venv had no OpenSandbox SDK and every sandboxed session failed. Pin the versions tested with the OpenSandbox server. Signed-off-by: smohsenitahe <[email protected]>
Signed-off-by: Guyue Huang <[email protected]> (cherry picked from commit 3e2b323)
Signed-off-by: Guyue Huang <[email protected]> (cherry picked from commit 0e45b12)
benchmarks/babyvision_opencode_question_only: the 388 BabyVision rows with the bare question + boxed-answer suffix as the user text (no Python_call_gen instruction), for models trained on OpenCode's own system prompt. Same text as Python_call_gen's question_only on 388/388 rows. babyvision_opencode's prepare() gains output_fpath and question_only arguments; its default output is unchanged. opencode_agent.provider_id (default "nemo"): the provider id of the generated model_server entry. OpenCode's system prompt names the model "<provider>/<model>", so a model trained on another harness's sessions can see the same line. Signed-off-by: smohsenitahe <[email protected]>
Without --title, OpenCode 1.17.11 sends the policy one extra request per session to generate a title, under the session's own X-Session-Id. Its tokens are captured but not in the session's usage, so rollout_token_count_mismatch flagged 287 of 388 BabyVision rollouts, and the reasoning model spent a median ~1.4K output tokens on the title (at least 10% of rollouts hit the 32K cap). The sandbox path (#3639) and the standalone harness (#2884) already pass a title for the same reason. Checked with a fake OpenAI server: 3 requests (2 agent + 1 title) without --title, 2 with it; the agent requests are identical apart from the temp working directory. Signed-off-by: smohsenitahe <[email protected]>
…hat requests OpenCode (interleaved.field: reasoning) sends each earlier assistant turn's reasoning back in a `reasoning` field, which the strict assistant-message model forbids. With the agent's token-tracking proxy off -- the NeMo RL SingleController token-capture path, where OpenCode calls the policy model server directly -- every request after the first tool call was rejected with 422 and the session ended after ~1.5 model calls. sanitize_streaming_chat_body now removes `reasoning` from assistant messages, as the proxy's drop_echoed_reasoning already did. Nothing is lost: token capture pins the parent call's sampled tokens, and its lineage fingerprint ignores reasoning. Signed-off-by: smohsenitahe <[email protected]>
…benchmarks - Judge defaults to gpt-4o-mini on the OpenAI API; drop internal endpoint and harness references from configs, docs and prepare scripts. - Export a VERIFIER_FIXTURE (fixed judge replies) for gym env test. - Add manifests, READMEs and prepare.py tests for babyvision_opencode and babyvision_opencode_question_only. - Declare the legacy_agent environment server next to the agent. - Move visual_coding_opencode and opencode_vision_agent to managed uv projects (pyproject.toml + uv.lock); re-enable opencv-python-headless for the vision agent in component-lock-policy.json. - Add the environment to the README table. Signed-off-by: Danial MohseniTaheri <[email protected]>
…without ray Describe attach_images, vision, private_tmp, track_token_ids, session_nodes, session_exclude_actor_classes, session_sandbox and provider_id. The session-node tests need the optional ray extra, which this agent's venv does not install, so they skip without it. Signed-off-by: Danial MohseniTaheri <[email protected]>
Rebasing onto main drops the earlier merge commit, which also carried two resolutions: OPENCODE_CONFIG_CONTENT in the sandbox session's forwarded environment (system_prompt_mode="replace" needs it inside the sandbox), and the moved nemo_gym.core import path in three files. Imports re-sorted. Signed-off-by: smohsenitahe <[email protected]>
Seed files cover content written when a sandbox is created. A harness agent session usually receives a sandbox that is already running, often borrowed from the environment server, so it needs to write content afterwards. upload_text already does that for UTF-8 text by writing a temporary file and calling upload(). upload_bytes writes bytes unchanged the same way, and upload_text now delegates to it. The sandbox docs show both helpers. Signed-off-by: Ananth Subramaniam <[email protected]> (cherry picked from commit f947fbd)
Harness agents receive media as Responses content parts, such as an input_image part holding a base64 data URI, while harness CLIs read media from files. nemo_gym/media_utils.py gives agents one place for that: split_text_and_media decodes a message into its text and media files, upload_media writes them into a sandbox, download_media reads a sandbox file back, and MediaFile converts to and from data URIs. Content it cannot pass on raises UnsupportedContentError, so a caller rejects the request instead of dropping the content. Images are supported today; audio and video need entries in its type tables. download_bytes joins upload_bytes in nemo_gym/sandbox/utils.py, and read_text delegates to it. Signed-off-by: Ananth Subramaniam <[email protected]> (cherry picked from commit a3fc3d6)
The opencode_agent session path rejected any input_image part with a 422, and its model entry declared no image input. OpenCode omits every image from model requests for a model without image input, including images its read tool returns, while still reporting the read as successful. A session now accepts base64 data-URI input_image parts in the user task. The adapter decodes them with nemo_gym.media_utils, uploads them into the session directory, and passes each one to `opencode run --file`. The session model entry declares image input, so images the read tool returns reach the model. Media outside the user task and image URLs are still rejected with a 422. Ported onto main 792fa14 for the Agentic-MME stack (#5720): main's session input now also takes request sampling, and test_unset_extensions_keep_setup_activation_and_capture_unchanged now expects the image options in the model entry. The #4922 test reads the staged activation through params(). Signed-off-by: Ananth Subramaniam <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> (cherry picked from commit 7a79506)
…a session's config Training on OpenCode rollouts needs one chain of model calls per rollout, and a fair comparison with other harnesses needs a step budget. The session path accepted only permission and tools, so neither could be set. A session's opencode_config now also accepts compaction.auto (a boolean) and agent.build.steps (a positive integer), and still refuses everything else, including compaction.prune (it rewrites old tool output, which breaks the token prefix) and other agent fields (they would replace the adapter's prompt, model or sampling). The replacement system prompt and the request sampling now join each agent's entry instead of overwriting it, and the session copies opencode_config instead of mutating the shared one. Tests: the allowlist, both prompt modes, request sampling beside a step limit, and the real OpenCode 1.17.11 binary reading steps from the session config (GYM_TEST_OPENCODE_BINARY). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> (cherry picked from commit f22f699)
… describe the step limit as OpenCode applies it From the call at the step limit on, OpenCode 1.17.11 adds an assistant message (MAX_STEPS_PROMPT) to each request. The fingerprint join of token capture finds no earlier call for such a request and records a capture failure, so NeMo-RL drops the rollout as poisoned, with only the finalize/capture_poisoned_rollouts metric to show it. With forest training the call starts a new chain instead, the same break that compaction.auto: false avoids. So with token capture on, a session's seed now refuses agent.build.steps with 422. Eval without token capture is unchanged. OpenCode also still offers the tools at the limit, with tool_choice auto, so a model that keeps calling them runs past it. The docstring and the README now say so instead of "caps the model calls". The harness guide's OpenCode row lists the session keys the README lists. Test: with token capture on, a seed with agent.build.steps gets 422 and starts nothing; compaction.auto alone still seeds. The test fails on the previous code. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> (cherry picked from commit 7586192)
…within it NeMo RL sets max_output_tokens on every row (its generation limit). An OpenCode sandbox session refused the field, so an OpenCode training run under NeMo RL failed its first episode with 422 "does not support request field max_output_tokens", and RL stopped the run. A session now accepts max_output_tokens when it is at least the configured max_output_tokens, which is OpenCode's own limit for each model call. A smaller value is still refused, so nothing is silently ignored. Test: a NeMo RL row (temperature 1.0, top_p 1.0, max_output_tokens 4096 or 16384 with a configured limit of 4096) passes, and OpenCode keeps the limit of 4096. The test fails without this change. The existing refusal of max_output_tokens 123 still passes. 819 OpenCode tests pass. The same change ran in the run C and D smokes (3 steps each). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> (cherry picked from commit af3c63b)
…ge toolkit OpenCode sandbox sessions run the model's shell in a sandbox, not in the agent server's venv, so the toolkit that opencode_vision_agent gives the model must be in the sandbox image. The image has Pillow 13.0.0, NumPy 2.5.4, SciPy 1.18.1 and opencv-python-headless 5.0.0.93 (the versions that opencode_vision_agent's uv.lock pins), one thread per numeric library as that agent sets, bash and ripgrep for OpenCode's tools, and OpenCode 1.17.11 under /opt/opencode/bin. A sandbox that reaches only the model server cannot download OpenCode, so the binary is in the image. Not built here. The pins resolve to Linux x86_64 wheels for Python 3.13 (uv pip compile). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…essions visual_coding_opencode.yaml runs the OpenCode CLI on the agent's host (opencode_vision_agent). The new configs/sandbox_sessions.yaml runs the same rows, prompt and judge with opencode_agent in a sandbox session: the Environment Server (single_agent_turn_legacy) seeds a session, sends the task and closes it, and each session creates its own sandbox through the `sandbox` provider. - The prompt image goes into the sandbox and is attached with `opencode run --file`. The model entry declares image input, so `read` returns images to the model. - Gym's token capture records each model call. Compaction is off and there is no step limit, because capture cannot join a compaction summary or a step-limit message to the scored calls. - The OpenCode settings match visual_coding_opencode.yaml: OpenCode 1.17.11, no thinking, 1800 s, a 131072-token context window and 32768 output tokens. Permissions allow every path and repeated tool calls, so experimental.continue_loop_on_deny (which a session refuses) is not needed. Subagents, webfetch and websearch are off. - The sandbox reaches only the model server (network_access: model_only), and only the model servers advertise this host's address. The agent that runs the CLI on the host is not started. Test: the three example rows run through a seeded session with the config's OpenCode settings. The prompt text is the row's text, the image bytes are uploaded and passed with --file, and the OpenCode config has image input, compaction off, the permissions and no subagents. 852 opencode_agent tests pass (30 skipped). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
benchmarks/babyvision_opencode/sandbox_sessions.yaml and the question-only twin run the same BabyVision rows on the visual_coding_opencode sandbox-session config, so BabyVision runs with opencode_agent in a sandbox and Gym's token capture, for evaluation and RL training. The READMEs say how to run them. Test: both configs resolve with Gym's config parser. They start the policy, the resources server, the judge, the session agent and an Environment Server that pairs the two; they do not start the agent that runs the CLI on the host. The session agent reaches only the model server and declares the same dataset entry as the benchmark's config.yaml. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…n in sandbox sessions A judge reply without a JSON object or a valid verdict used to count as "unsure", and a JudgeError was caught and scored 0. RL then trained on the row as a wrong answer. Now parse_verdict raises JudgeError for such a reply, and verify() lets judge failures propagate, so the base class's judge_failsafe returns the row masked (mask_sample, failure_kind judge_failed). "unsure" still scores 0 when the judge says it. The sandbox-session config now sets thinking: true, for a reasoning policy. A model without reasoning sets it to false. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…server starts sandboxes The resources server lends each episode a sandbox, so its environment needs nemo-gym[sandbox]: without it, every seed on the OpenSandbox provider failed with "tenacity is required for OpenSandbox retry handling" (HTTP 500). Agentic-MME's resources server, which lends sandboxes the same way, already depends on nemo-gym[dev,sandbox]. Test: a live smoke on the example rows failed every seed with this error before the change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
Contributor
Author
|
/ok to test b5dd2ff |
…outs, so the data check passes The server test's data check expects 5 example rows, their metrics and 5 example rollouts; the server had 3 rows and neither file, so CI failed on it. - example.jsonl adds BabyVision tasks 4624 (Spatial Perception, Count 3D blocks) and 487 (Visual Pattern Recognition, Logic Patterns) from the UnipatAI/BabyVision dataset on Hugging Face (MIT license), revision 849cbeea2b1d00ad334e9e1e2b49a1960c9ff3f3, in prepare.py's format. A multiple-choice question lists its options as (A), (B), ... and its answer is the option's letter, as VLMEvalKit builds them. The README names the source. - example_metrics.json comes from `gym dataset collate ... +mode=example_validation`. - example_rollouts.jsonl is one rollout of each row: OpenCode in a lent, model-only sandbox, a hosted vision-language policy and a gpt-4o-mini judge. Four rows score 1.0; task 4624 ends incomplete and scores 0. Test: `gym env test +entrypoint=resources_servers/visual_coding_opencode +should_validate_data=true`: 25 passed, and the data validates. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
Contributor
Author
|
/ok to test 50013c7 |
… helpers this branch needs Copies of commits from the multi-harness core stack (#5719 and the PRs it depends on), which BabyVision's sandbox sessions need. They drop out when that stack merges to main. - `upload_bytes` and `download_bytes` for a running sandbox, and bytes in `SandboxSpec.files`. - `nemo_gym/media_utils.py`: media in Responses messages and sandboxes (prompt images for agent sessions). - `LentSandboxes`: the sandbox a resources server lends to a harness, one per resources session, with its stop, cancellation and shutdown fixes, and the `model_only` network option (the lent sandbox reaches only the model server). `restricted_network_policy` moves to `nemo_gym.utils.network_policy`; `nemo_gym.agents` still exports it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
… the host-CLI vision path BabyVision runs through `opencode_agent` sandbox sessions behind the Environment Server. Gym core's token capture records each model call there, so the agent-side paths that this PR added for the host CLI are not needed: - `opencode_vision_agent` and its lock policy entry; - in `opencode_agent`: `attach_images`/`vision`, `session_sandbox` (with its host-file and outage fixes), `session_nodes`, `provider_id`, the local-run session title and process-group changes, and the `repo_dir` check for remote sessions; - the chat-stream drop of an echoed `reasoning` field, which only the host path's `interleaved.field: reasoning` needed (sessions use `reasoning_content`). `track_token_ids` was already gone; NeMo RL's sampler top-k capture covers score centering. `opencode_agent`, its README and its tests are main plus copies of the multi-harness stack's session commits: prompt images attached with `opencode run --file`, `compaction.auto` and `agent.build.steps` in a session's config (refused with token capture), and NeMo RL's per-row `max_output_tokens` accepted when OpenCode stays within it. Those copies drop out when that stack merges. `tests/test_visual_coding_sessions.py` runs the BabyVision example rows through a seeded session with this config's OpenCode settings. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
… a lent, model-only sandbox - The environment config runs each task with `opencode_agent` in a sandbox session behind the Environment Server. Gym's token capture records every model call, so the same config serves evaluation and RL. Compaction is off and there is no step limit, so capture can join every call. Thinking is on. - The resources server lends the sandbox: a typed seed starts it through `LentSandboxes` and returns its `SandboxAccess`, and the close stops it (shutdown stops any still lent). A repeated seed gets the same sandbox; a seed for another episode or a closed session gets 409. `sandbox_network_access: model_only` with `sandbox_model_server: policy_model` lets the sandbox reach only the policy model. The sandbox settings (image, TTL, 2 CPUs and 8 GiB) are on the resources server; the agent keeps `network_access: inherit`. The task-data schema is unchanged. The server now depends on `nemo-gym[dev,sandbox]`. - A sandbox image (`sandbox_image/Dockerfile`) with the Python image toolkit and OpenCode 1.17.11 preinstalled. - A judge failure (a failed call, or a reply without a valid verdict) is masked (`judge_failed`) instead of scoring 0; `"unsure"` still scores 0. - Both BabyVision configs and manifests run through `opencode_agent`. The visual-coding guide describes this setup. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…outs, so the data check passes The server test's data check expects 5 example rows, their metrics and 5 example rollouts. - example.jsonl adds BabyVision tasks 4624 (Spatial Perception, Count 3D blocks) and 487 (Visual Pattern Recognition, Logic Patterns) from the UnipatAI/BabyVision dataset on Hugging Face (MIT license), revision 849cbeea2b1d00ad334e9e1e2b49a1960c9ff3f3, in prepare.py's format. A multiple-choice question lists its options as (A), (B), ... and its answer is the option's letter, as VLMEvalKit builds them. The README names the source. - example_metrics.json comes from `gym dataset collate ... +mode=example_validation`. - example_rollouts.jsonl is one rollout of each row: OpenCode in a lent, model-only sandbox, a hosted vision-language policy and a gpt-4o-mini judge. Four rows score 1.0; task 4624 ends incomplete and scores 0. Test: `gym env test +entrypoint=resources_servers/visual_coding_opencode +should_validate_data=true`: 25 passed, and the data validates. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…Vision PR's rebased head DanialTaheri/Gym babyvision-opencode-env was rebased to 3d7e6ff (on main 72275b8). The merged branch puts this PR's changes on that head as four commits: the multi-harness stack helpers it needs, opencode_agent as main plus the session commits, BabyVision on sandbox sessions with a lent, model-only sandbox, and the example data. This merge takes that branch's tree as is, so the PR's diff against the new base (a copy of 3d7e6ff) is exactly those changes. No history is rewritten. Signed-off-by: Yi-Fu Wu <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
yfw
changed the base branch from
yifuw/babyvision-opencode-env-base
to
yifuw/babyvision-danial-base-3d7e6ffed
November 9, 2026 08:30
Contributor
Author
|
/ok to test 52beadf |
…he tutorial's index card The card still described the host CLI and session_sandbox runs, which this branch replaces with sandbox sessions. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
Contributor
Author
|
/ok to test 772cfb9 |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Draft for review before this goes to the BabyVision PR's branch (DanialTaheri/Gym
babyvision-opencode-env). The base branchyifuw/babyvision-danial-base-3d7e6ffedis a copy of that PR's head (3d7e6ffed), so the Files tab shows only the changes in this branch. They are four commits on that head (the stack helpers it needs,opencode_agentback to main plus the session commits, BabyVision on sessions with a lent sandbox, and the example data), brought in by the merge commit52beadf61without rewriting this branch's history; the Commits tab therefore also lists this branch's earlier commits. The task-data schema, the dataset md5 note and the visual-coding guide from that head are kept; the guide is rewritten for sandbox sessions.session_sandboxandsession_nodes, with their latest fixes, are replaced by sandbox sessions.What changes and why
This PR moves visual coding and BabyVision to
opencode_agentin a sandbox session. In a sandbox session, the Environment Server opens an agent session, sends the task and closes the session. Each task runs OpenCode in its own sandbox, which the resources server lends, and Gym's token capture records each model call. The same config then serves evaluation and RL training.This branch keeps these parts of the BabyVision PR:
visual_coding_opencoderesources server and its GPT judge (with the judge change below);opencode_agent);opencode_vision_agent's lock pinned.Changed or new in this branch:
resources_servers/visual_coding_opencode/configs/visual_coding_opencode.yamlruns each task withopencode_agentin a sandbox session. Compaction is off, and there is no step limit, so token capture can join every model call. Both BabyVisionconfig.yamlfiles run their rows through it.The resources server lends the sandbox. Each episode's seed starts one through
LentSandboxesand returns itsSandboxAccess; the episode's close stops it, and shutdown stops any still lent. A repeated seed gets the same sandbox, and a seed for another episode or a closed session gets 409. The sandbox settings (image, TTL, 2 CPUs and 8 GiB) are on the resources server, and the agent keepsnetwork_access: inherit, as a borrowed sandbox requires. Withoutsandbox_provider, the server stays stateless as before. Grading never reads the sandbox.The lent sandbox reaches only the policy model:
sandbox_network_access: model_onlywithsandbox_model_server: policy_model. A new commit adds this option toLentSandboxes(network_access,model_server): it builds the same egress rule that an agent-owned sandbox gets withnetwork_access: model_only, and refuses the seed with 422 when the provider has no network policies or the model server has a loopback address.restricted_network_policymoves tonemo_gym.utils.network_policy, belowserver_runtimein the package layers;nemo_gym.agentsstill exports it. This commit is written so that it can also go onto the multi-harness stack.A sandbox image (
resources_servers/visual_coding_opencode/sandbox_image/Dockerfile) with the toolkit and OpenCode preinstalled.Thinking is on, for a reasoning policy. Set
thinking: falsefor a model without reasoning.A judge failure no longer scores 0. A failed judge call, or a judge reply without a valid verdict, now reaches the base class's
judge_failsafe, which returns the row masked (mask_sample,failure_kind: judge_failed). RL then does not train on it as a wrong answer."unsure"still scores 0 when the judge says it.From the multi-harness stack, the commits that the session path needs:
upload_bytes;opencode run --file, with image input declared on the model;compaction.autoandagent.build.stepsin a session's config, and a refusal ofagent.build.stepswhen token capture is on;max_output_tokenswhen it is at least OpenCode's limit;SandboxSpec.files, andLentSandboxeswith its follow-up fixes.These commits drop out when that stack merges to main.
Removed
This branch removes the BabyVision PR's own OpenCode agent path, which sandbox sessions replace:
attach_imagesandvisioninopencode_agent;track_token_idsandtoken_tracking.py;session_sandboxandsession_nodes;opencode_vision_agentcomponent and its lock policy entry;generation_topk_*token metadata fields and theirvllm_modelnormalization, which fed onlytrack_token_ids. Score centering is covered by NeMo RL's sampler top-k capture through token capture;reasoningfield, which only that path'sinterleaved.field: reasoningneeded. Sessions usereasoning_content.opencode_agent, its README and its tests are back to main plus the session commits above.On the removed path, training had three problems:
track_token_idsskipped the capture prefix, so RL masked every rollout.The session path does not have these problems. Gym core capture records the calls, and RL keeps the exact pixels that each call sent. With one path, each OpenCode change also gets made only once.
Validation
/verifyand expect a maskedjudge_failedrow for a failed call, a reply that is not JSON and a reply without a valid verdict.opencode_agentwith the resources server, that compaction is off with no step limit, and that the rows match each manifest.resources_servers/visual_coding_opencode/tests/test_sessions.pyseeds, re-seeds and closes on the local sandbox provider, runscheck_resources_session_contract, stops every lent sandbox at shutdown, checks thatmodel_onlyputs the policy model's host in the sandbox's egress rule, and refuses settings that cannot work at startup.tests/unit_tests/server_runtime/test_sandbox_lending.py: 13 passed, 4 of them formodel_only. The agents, server_runtime and opencode_agent unit tests pass (opencode_agent: 826 passed).Rollout evidence (eval smoke at
b5dd2fffd, on an OpenSandbox deployment, with a hosted vision-language policy through Gym's model server and a gpt-4o-mini judge):sandbox_network_access: model_only. 6 of 6 rollouts completed and were scored, with no masked or failed rows. All 6 answers matched the gold answer (judge verdictequivalent, reward 1.0). Two rollouts used a tool call. The median rollout took 2.3 minutes.curlinside the lent sandbox. An internet host did not resolve (curl exit 6), and the policy model's address answered HTTP 200. The close stopped the sandbox, and the server logged no failed stop.b5dd2fffd, failed every seed: the resources server's environment did not have the sandbox extra. That commit adds it.Example data (
50013c754):example.jsonlhas five rows, the three synthetic ones and BabyVision tasks 4624 and 487 fromUnipatAI/BabyVision(MIT license, revision849cbeea2b1d00ad334e9e1e2b49a1960c9ff3f3, named in the README), withexample_metrics.jsonandexample_rollouts.jsonlfrom the same eval setup (four rows score 1.0; the 3D-block counting task ends incomplete and scores 0).gym env test +entrypoint=resources_servers/visual_coding_opencode +should_validate_data=truepasses.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, this branch's config with lent model-only sandboxes):
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