Repository navigation
feat(ui_generation_agentic): add an agentic UI generation environment - #6012
Conversation
A coding harness writes one front-end UI file from scratch in a sandbox that holds a ready-made project (Next.js, Vite or a static nginx page). The ui_generation_agentic resources server lends each episode's sandbox to the harness through single_agent_turn (taskset routing), then grades in the same sandbox once the agent session has closed: - G1 stops processes the agent left running; G2 snapshots the entry file; G3 checks the image's read-only template and toolchain against their manifest; G4 builds the snapshot in a fresh copy of the template with a verify script uploaded at verify time; G5 (guard_mode: full) builds as an unprivileged user; G6 takes the verdict from the build and the judge. - An LLM judge (the ui-code-judge-v1 rubric from resources_servers/ ui_generation, adapted to have no reference answer) scores quality and prompt adherence; reward = build x quality / 4. - guard_mode: detection_only supports sandboxes whose commands cannot switch user, such as a self-hosted OpenSandbox server. - With agent_network_mode: restricted, the sandbox reaches only the policy model server and Google Fonts (OpenSandbox egress policy). Harness compositions in environments/ui_generation_agentic/ share the harness-neutral base.yaml: opencode.yaml (runtime baked into the images), claude_code.yaml and hermes.yaml (runtimes uploaded at seed) and codex.yaml (runtime baked into the images built with WITH_CODEX=1). Each harness calls the policy Gym model server from inside the sandbox. prepare.py turns a UI-generation JSONL into task rows (only the first user prompt and the stack are read) with a task template that, by default, asks every harness to build the file in steps, so no reply nears the per-call output cap (ui_generation_agentic_max_output_tokens, default 32768). Rollouts record the build, judge, guard and network fields and agent_stop_reason. task_data.py describes the dataset rows. docker/ holds self-contained Dockerfiles and build_images.sh for the three agent images; users build and publish their own. An optional stage (WITH_CODEX=1) runs Codex's pinned installer (Node 22.19.0 and @openai/codex 0.144.4, Apache-2.0) into a read-only runtime dir outside the template manifest, and the images set TMPDIR=/var/tmp, since Codex refuses to create its helper binaries under the temp dir. data/example.jsonl holds three hand-written tasks; no task data ships with the environment. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Somshubra Majumdar <[email protected]>
…r detect-secrets The secrets detector flagged the three public SHA-256 pins in environments/ui_generation_agentic/opencode.yaml (the OpenCode binary, ripgrep and the plugin dependencies) as hex high-entropy strings. Mark them with an inline pragma: allowlist secret, as other configs in the repository do for public digests. The parsed values are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Somshubra Majumdar <[email protected]>
|
/ok to test a8123ba |
|
/review |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
HOLD
Two BLOCKER findings affect grading integrity: agent processes can survive G1 by using an exempt process name, and the clean build can consume agent-written files from .vite-temp. The remaining findings cover full-mode cleanup, session ownership and release, response construction, metrics, preparation, and documentation.
I completed the three-topic review and traced the directly affected contracts. This was a static review: I couldn't execute tests, build images, or reproduce the reported rollouts. The acceptance checks below are proposed, not executed.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
yaoyu-33
left a comment
There was a problem hiding this comment.
Thanks for this. An agentic UI-building environment with a build gate, tamper guards and four harnesses is a useful addition, and the rollout table per harness is clear.
This review builds on the existing threads rather than repeating them. We checked each of them against the code at a8123ba and they hold, including the two G1/.vite-temp blockers, so they are not restated here. The new points are inline. Most of them are about the same question as those blockers: when an infrastructure fault gets scored as a wrong answer, or when an agent fault gets masked instead of scored. The reward depends on getting those two cases right.
We also replied on six existing threads where we had something to add, mainly the shared cause behind the seed, close and retire threads (the server overrides the base session hooks).
Not verified here: no sandbox, image build or real rollout was run. Server tests (11) and tests/unit_tests/data/test_task_data.py pass. CI's example-data check still fails as noted in the existing thread.
| for f in $(ls -A "$TEMPLATE"); do | ||
| [ "$f" = node_modules ] || cp -a "$TEMPLATE/$f" "$DIR/" || exit 90 | ||
| done | ||
| ln -s "$TEMPLATE/node_modules" "$DIR/node_modules" || exit 90 |
There was a problem hiding this comment.
resources_servers/ui_generation_agentic/scripts/ui_gen_verify.sh:17-29
RISK. The fresh build still reads files the agent can write, beyond .vite-temp (existing thread above). The build dir is /tmp/ui-gen-verify.X/build, and only build/node_modules is the template, so a bare import the template lacks resolves from /tmp/node_modules (/tmp is 1777 and G1 deletes no files). An absolute import such as /app/src/helper builds against the agent's workspace. See Vite's parent-dir lookup (packages.ts#L87-L123) and absolute-path resolution (resolve.ts#L326-L332). A deliverable that would not build in a clean template can therefore score build_passed.
Could you build under a root-owned parent directory (for example mktemp -d under a 0755 root /opt/ui-gen/work), and fail an entry that imports outside the template? The "nothing the agent changed reaches the build" claim in resources_servers/ui_generation_agentic/app.py:23-24 and the README would then hold.
| if full: | ||
| await self._exec( | ||
| sandbox, f"mkdir {work}/build && chown -R {self.config.verifier_user} {work}", user=root | ||
| ) |
There was a problem hiding this comment.
resources_servers/ui_generation_agentic/app.py:463-468
RISK. The mkdir/chown result is never checked. In full mode mktemp -d makes a root-owned 0700 dir, so if this step fails (or returns an error_type), bash {work}/verify.sh as ui-verify cannot open the script. bash then exits 126/127, not 90, and the row is scored build_failed, a 0 for an infrastructure fault. Separately, _exec raises _Inconclusive out of the for attempt loop, so inconclusive_verification_retries never covers a provider exception on mktemp/mkdir/the build, only upload failures and error_type results.
Could you check error_type/return_code here and continue on failure, treat 126/127 from the bash call as setup failure, catch _Inconclusive inside the loop, and shlex.quote verifier_user and work?
| if result.error_type not in (None, "timeout") or result.return_code == VERIFIER_SETUP_EXIT: | ||
| last_error = f"build could not run: {result.error_type or 'verifier setup failed'}" | ||
| continue | ||
| grade.build_exit_code = 124 if result.error_type == "timeout" else result.return_code |
There was a problem hiding this comment.
resources_servers/ui_generation_agentic/app.py:476-482
RISK. A provider-level exec timeout (error_type == "timeout" at build_timeout_s + 120) is recorded as the script's own exit 124 and scored build_timeout (0). It fires only when timeout(1) did not end the build or the provider stalled, so the outcome is unknown. The two need fixing together: add timeout -k 10 "$TIMEOUT" in resources_servers/ui_generation_agentic/scripts/ui_gen_verify.sh:26 and resources_servers/ui_generation_agentic/scripts/ui_gen_verify.sh:29 so a build that ignores SIGTERM still ends as 124 and is scored, then treat the outer timeout as inconclusive (retry, then mask). Masking alone would let a hanging deliverable dodge its 0.
| raise _Inconclusive( | ||
| VERIFIER_ERROR, f"could not stop the agent's processes: {result.stderr or result.stdout}" | ||
| ) | ||
| if int(left) != 0: |
There was a problem hiding this comment.
resources_servers/ui_generation_agentic/app.py:399-400
RISK. The agent can turn a failed episode into a masked one. G1 lists its processes, kills them once, waits 1 s and counts again (_G1_KILL, L103-L108). A fork loop left running spawns children in between, so left > 0 and the row is masked as harness_termination_unconfirmed instead of scored. Could you repeat kill-and-recount a few times before giving up, and record the surviving commands? In full mode, survivors owned by the agent user after that are the agent's doing and could be scored 0.
| if facts.get("manifest") != "ok": | ||
| grade.tamper_details.append("template or toolchain differs from its manifest") | ||
| if stack.manifest_sha256 and facts.get("manifest_sha") != stack.manifest_sha256: | ||
| grade.tamper_details.append("manifest file differs from the pinned SHA-256") |
There was a problem hiding this comment.
resources_servers/ui_generation_agentic/app.py:436-437
RISK. The agent cannot change the pinned manifest: the template and MANIFEST.sha256 are root-owned and a-w, and the agent runs as node/ui. A mismatch with UI_GEN_*_MANIFEST_SHA256 therefore means a wrong pin or a rebuilt image, yet it scores every sample of that stack 0 as tamper_detected. Could you check the pin once (at startup or first seed, refusing with ResourcesSeedRejectedError) instead of scoring it per row? manifest=bad and newer can stay scored.
| @@ -0,0 +1,32 @@ | |||
| #!/bin/bash | |||
There was a problem hiding this comment.
resources_servers/ui_generation_agentic/scripts/ui_gen_verify.sh:1
NOTE. This new file needs the NVIDIA SPDX header after the shebang (AGENTS.md).
| timeout: 3600 | ||
| # The sandbox environment is the agent image's own; Codex needs its TMPDIR (/var/tmp), since it refuses to create | ||
| # its helper binaries under the temp dir and its sessions live under /tmp. | ||
| inherit_sandbox_environment: true |
There was a problem hiding this comment.
environments/ui_generation_agentic/codex.yaml:27-29
NOTE. This works around a codex_agent issue (CODEX_HOME under /tmp, so Codex refuses its helper binaries) through the task image's TMPDIR plus inherit_sandbox_environment, which hands Codex the whole sandbox environment. Could the fix go into codex_agent (move CODEX_HOME or set TMPDIR in its launcher) in a separate PR, so this composition stops depending on the image?
| # Agentic UI generation: a coding harness writes one UI entry file from scratch in a per-stack sandbox that this | ||
| # resources server lends through single_agent_turn; this server then builds the snapshotted file in a fresh copy | ||
| # of the image's template and scores it with an LLM judge (reward = build x quality / 4). Run it through a harness | ||
| # composition in environments/ui_generation_agentic/ (opencode.yaml, claude_code.yaml, hermes.yaml), which |
There was a problem hiding this comment.
resources_servers/ui_generation_agentic/configs/ui_generation_agentic.yaml:4-5
NOTE. This comment, environments/ui_generation_agentic/base.yaml:2-3 and L19 list only OpenCode, Claude Code and Hermes; codex.yaml is missing, and L19 could say Codex takes its cap from the model server.
|
|
||
| `ui_generation_agentic_max_output_tokens` (default 32768; override per run with | ||
| `++ui_generation_agentic_max_output_tokens=<n>`) is the output cap of OpenCode and Hermes for each model reply: | ||
| reasoning plus one tool call. Claude Code keeps its own CLI default (32000), which a `settings` file can change through |
There was a problem hiding this comment.
resources_servers/ui_generation_agentic/README.md:134-138
NOTE. The harnesses run with different limits: Claude Code and Hermes cap turns at 100, OpenCode and Codex have none; Hermes inherits temperature: 1.0; each output cap comes from a different place. Since the PR compares harnesses on one verifier, could the README list these next to the comparison?
| ("codex", "ui_generation_agentic_codex_agent", "codex_agent"), | ||
| ], | ||
| ) | ||
| def test_each_harness_composition_routes_episodes_to_its_agent_on_the_policy_model( |
There was a problem hiding this comment.
resources_servers/ui_generation_agentic/tests/test_app.py:119
NOTE. This test and test_the_agent_output_cap_is_one_environment_item_defaulting_to_32k assert YAML wiring, which gym env resolve/validate and the pairing runs already cover; the repo keeps no unit tests for configs. The space is better spent on the verify() tests above.
…on environment Sessions use the base session-state hooks (has/initialize/release_session_state and verifying()), so seed binds episode and task, a failed seed's sandbox is released on close, retirement releases state, and a verify retry judges the retained grade. Guards: - G1 spares the sandbox runtime by process identity (PID + start time) recorded at seed, not by name; up to 10 kill rounds; survivors are reported. Full mode targets each stack's agent_user (node / ui) and keeps the Docker provider's keep-alive. - G4 builds with a private node_modules of links to the installed packages (no .vite-temp, .vite, .cache) and a Vite/webpack guard that fails the build when the entry reads any file outside the build directory and those packages; full mode builds under a root-owned parent. - Every build setup step is checked; 90/126/127 and provider exec timeouts are inconclusive and retried; the build runs under timeout -k 10. - The manifest pin is checked at seed (422 on mismatch); an empty integrity answer masks. Scoring: computed fields win over request fields; the seeded task is graded; reward_score (quality, prompt_adherence, mean, min) replaces reward_mode; files over 256 KiB score 0 before the judge; the observed judge grading returns the verify response; per-stack masked rates come from aggregate_metrics over all rows; shutdown stops all stacks concurrently. Judge: code fenced longer than any backtick run; first fenced JSON object, any tag case. Static build needs a doctype or <html> and </html>. prepare.py fills placeholders in one pass, skips bad rows and checks duplicates per stack. Config: mandatory judge settings, judge model server on 127.0.0.1, unset stack images refused at seed, restricted egress refused at startup for non-OpenSandbox providers or a user-set network_policy, verify_after_agent_error for Codex. Images: digest-pinned bases, committed package-lock.json + npm ci for Next and Vite, OpenCode checked by SHA-256. Data and docs: five synthetic example tasks with example_metrics.json and five OpenCode example rollouts collected with the documented smoke recipe; README updates; new Fern evaluation tutorial linked from the Coding environment list. Tests cover verify, guards, sessions (check_resources_session_contract), judge parsing, prepare and metrics. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Somshubra Majumdar <[email protected]>
|
/ok to test debe8ae |
|
/ok to test a5f2555 |
|
/review-approve role=automation |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
I verified the prior findings against the current head and found no eligible unresolved issues.
The identity-based G1 cleanup addresses the reported process-name bypass. Seed-time runtime identities and stack-specific accounts address the keepalive and static-user failures. The private dependency directory closes the reported .vite-temp/helper.js import path.
The session hooks address ownership and release failures. I also verified the response-construction, metrics, template-rendering and observation-binding fixes. The revised smoke recipe uses materialized input, and the new tutorial is reachable through the documentation navigation.
This was a follow-up from a8123ba, limited to prior findings and introduced regressions above the historical moderate impact ceiling. It was not a fresh whole-PR review. I inspected the relevant regression tests but did not execute tests or sandbox/image validation.
Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.
…block The latest-docs check rejects VAR=<...> assignments in bash blocks, since they are a syntax error when pasted. Export a sample IMAGE_PREFIX and build the digest references from it instead. Signed-off-by: Somshubra Majumdar <[email protected]>
Signed-off-by: Somshubra Majumdar <[email protected]>
b835b57
|
/ok to test b835b57 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/44377915224 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/44379217684 |
What
A new environment,
ui_generation_agentic: a coding harness writes one front-end UI file from scratch inside a sandbox that holds a ready-made project, and the resources server grades that file by building it and asking an LLM judge.ui-nextapp/sample.tsxui-vitesrc/App.tsxui-staticindex.htmlsingle_agent_turnwith taskset routing. The resources server lends each episode's sandbox to the harness (LentSandboxes). After the agent session closes, it grades in the same sandbox:guard_mode: full) builds as an unprivileged user.build × quality / 4. The judge rubric isui-code-judge-v1fromresources_servers/ui_generation(feat(ui_generation): add UI generation environment with an LLM-judge verifier #5774), adapted to have no reference answer. A sandbox or judge failure masks the sample; a missing deliverable, a failed build or a changed template scores 0.agent_network_mode: restricted, the sandbox reaches only the policy model server and Google Fonts (OpenSandbox egress policy viarestricted_network_policy).guard_mode: detection_onlysupports sandboxes whose commands can't switch user.environments/ui_generation_agentic/, all on a harness-neutralbase.yaml:opencode.yaml: OpenCode 1.17.11, runtime baked into the images.claude_code.yaml: Claude Code 2.1.108, binary uploaded at seed. It uses the model server's/v1/messageswith placeholder credentials.hermes.yaml: Hermes, runtime built on the Gym host and uploaded at seed.codex.yaml: Codex 0.144.4, runtime baked into the images when they are built withWITH_CODEX=1(the sandbox has no internet). Codex has no per-call output cap of its own, so its cap is set on the model server.prepare.pyturns a UI-generation JSONL into task rows. It reads only the first user prompt and the stack, and ignores any assistant answer. By default the task template asks every harness to build the file in steps (a short working version, then edits of at most a few hundred lines), so no reply nears the per-call output cap (ui_generation_agentic_max_output_tokens, default 32768). It is part of the user message, so no harness setting is needed.agent_stop_reason.resources_servers/ui_generation_agentic/docker/has self-contained Dockerfiles andbuild_images.shfor the three agent images. Users build and publish their own images and pointUI_GEN_*_IMAGEat the digests. The Dockerfiles hold only public npm pins, the stack configs, and pinned OpenCode/ripgrep downloads checked by SHA-256. An optional stage (WITH_CODEX=1) runs Codex's own pinned installer (responses_api_agents/codex_agent/install_codex_runtime.sh: Node 22.19.0, checked against nodejs.org's SHASUMS256, and@openai/codex0.144.4, Apache-2.0). It adds about 540 MB per image and leaves the template manifest unchanged.data/example.jsonlholds three hand-written synthetic tasks, written with AI assistance.task_data.pydescribes the row schema.Why
To generate agentic UI-building traces and rewards across harnesses on a common verifier. The existing
ui_generationserver grades single-turn answers; this environment runs the same kind of task as an agentic episode in a sandbox, with a build check and tamper guards.Issue: none. This is a new, self-contained environment.
Validation
pytest resources_servers/ui_generation_agentic/tests: 11 passed. Covers the agent stop reason, metrics, output-cap wiring, the default step-by-step task prompt, and each harness composition's agent wiring.pytest tests/unit_tests/environment tests/unit_tests/data/test_task_data.py: 1095 passed. This includes the newtask_data.pyschema and the committed example rows.pytest tests/unit_tests(full core suite): every failure is outside this change. They come from optional packages missing in my local environment (mlflow,cloudpickle,jinja2, wandb), not from this environment. None of them touchui_generation_agentic.pre-commit run --files <changed files>: all hooks pass.gym env resolveforopencode.yaml,claude_code.yaml,hermes.yamlandcodex.yaml. The OpenCode composition resolves the same as before the harness split, apart from ports.WITH_CODEX=1. Their OpenCode, ripgrep and plugin-dependency hashes and their template manifests match the pins in the config. With Codex,codex-cli 0.144.4runs from the read-only runtime dir as the agent user.Rollout evidence
Real rollouts on a self-hosted OpenSandbox server (Docker runtime,
dns+nftegress enforcement,guard_mode: detection_only):Before the step-by-step task template, OpenCode wrote each page in one 25K–36K-token reply, which a 32K cap would cut off. With the template, which is now the default, every harness creates a short first version and then edits it. Codex ran on the images built with
WITH_CODEX=1, with its 32K cap set on the model server.Every tool call had a recorded result. Reasoning is recorded in
response.output,ng_trajectoryand the per-call model captures. For Codex,response.outputlists eachapply_patchby path and kind only; the full patch is inng_trajectoryand the model-call captures.Known limitations and follow-ups
manifest.yamlyet: publishing one needs aVERIFIER_FIXTUREwith sandbox and judge stubs.gym eval export atifcurrently rejects OpenCode and Claude Code trajectories (their trajectory-turn item shapes); separate issue.vllm_modeldoesn't wait on them, so it isn't included./tmpand refuses to create its helper binaries under the temp dir, so the images setTMPDIR=/var/tmpandcodex.yamlsetsinherit_sandbox_environment: true.Compatibility
A new environment only. Shared code is unchanged.
🤖 Generated with Claude Code