Repository navigation
feat(agent): add prompt replacement and Pi tool controls - #5144
RyaliNvidia merged 3 commits into
Conversation
Signed-off-by: RyaliNvidia <ryali@nvidia.com>
yaoyu-33
left a comment
There was a problem hiding this comment.
One prompt-serialization issue below.
Signed-off-by: RyaliNvidia <ryali@nvidia.com>
|
/ok to test 0a67829 |
|
🌿 Preview your docs: https://nvidia-preview-pr-5144-39774fe62a3b.docs.buildwithfern.com/nemo/gym |
Signed-off-by: RyaliNvidia <ryali@nvidia.com>
|
/ok to test 39774fe |
yaoyu-33
left a comment
There was a problem hiding this comment.
Re-reviewed at 39774fe.
The earlier {env:...} / {file:...} thread is resolved. Only the injected agent.build.prompt is escaped, in both the local and sandbox paths, and substitutions elsewhere in the config stay active. I round-tripped _serialize_replacement_config on about 5,000 generated prompts (braces, backslashes, a literal \u007b, control and non-BMP characters): each decodes to the original text, and neighbouring keys, their order and sibling {env:...} / {file:...} text come through unchanged. I did not re-run the pinned-CLI cases locally.
The merge from main is clean and the branch still merges into current main without conflicts. CI is green apart from the non-blocking harness-conformance KiloCode job already noted in the description. No blockers or risks left from my side.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/41513131179 |
Brings in main up to 94545e7 (#5141, #5384, #5144, #4615, #4954, #5001, #5175). Textual conflict: nemo_gym/cli/env.py, imports only. This branch imports PIPE from subprocess (the server start error capture); main imports SIGKILL from signal (#5141, the shutdown drain). Both are kept: "from signal import SIGINT, SIGKILL" and "from subprocess import PIPE, Popen, TimeoutExpired". Semantic conflict: #5141 starts each server in its own session (run_command(..., start_new_session=True)) so shutdown can signal its process group, while this branch starts servers through RunHelper._spawn_server, which keeps the tail of the error stream. The merged call passed start_new_session to _spawn_server, which did not accept it (11 test_cli failures). _spawn_server now takes start_new_session and forwards it to run_command, so both behaviours hold. The dry-run path keeps this branch's process.wait(): the tail thread of _spawn_server owns the piped stream, so main's communicate() would compete with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Adam Rajfer <arajfer@nvidia.com>
Resolve the conflicts with main's move of the agent modules into nemo_gym.agents (#5228) and OpenCode system prompt replacement (#5144): import from nemo_gym.agents, keep this PR's OpenCode config fields beside main's prompt-agent validator, and keep main's replacement config serialization with the shared OpenCode isolation variables. In a sandbox session, prompt replacement now adds the build agent's prompt instead of replacing the agent config, so request temperature and top_p still reach every OpenCode agent. A test covers it. Import the names main moved from their new packages (scripts/migrate_imports.py). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Katherine Huang <katherineh@nvidia.com>
What does this PR do?
Expose existing harness controls for custom system instructions and built-in tool selection. Pi and OpenCode gain
system_prompt_mode: append | replace, retaining append defaults. Pi'senable_tools: falseuses--no-builtin-toolswhile preserving separately granted MCP tools, output limits and outcome reporting.OpenCode replacement explicitly selects build, keeps the user task separate and rejects conflicting
--agentarguments. Local replacement uses a per-invocation config override, preserving sibling configuration without writing request-specific prompts into a persistent repository. Existing OpenCode tool selection, sandbox restrictions, plugins and continuation behavior remain intact.Preserve injected replacement prompts literally through OpenCode's pre-JSON
{env:...}/{file:...}substitution. Escape opening braces only in the serializedagent.build.promptvalue, so JSON decoding restores the original text. Both local and sandbox paths share this handling. Intentional substitutions elsewhere—including identical text in another agent's prompt—remain active. Append mode and configurations without an injected replacement use ordinary serialization.The branch incorporates main
c69f3b15ff794d6cb49418117748bb16be195cbb, retaining its sandbox runtime changes, canonical package imports and documentation additions. No separate issue is needed for this focused exposure of existing native controls.Validation
uv.lock --extra dev --extra sandboxthrough Gym's setup helper, then reused with++skip_venv_if_present=true. Commands usegym env test +entrypoint=responses_api_agents/<pi_agent|opencode_agent> +should_validate_data=true. Pi: 335 passed, 27 skipped. OpenCode: 592 passed, 50 skipped on the complete repeat.Sandbox.params()raisedKeyError('')). The unchanged case passed individually on both the PR and verified main; the complete unchanged repeat passed. No assertion or source was altered to obtain that result.\\u007btext.json.dumpsmakes both native literal regressions fail on the missing-file reference. Removing explicit build selection makes its native replacement regression fail because the replacement marker is absent. Normal substitutions in other configuration remain active.pre-commit run --all-files, Ruff/format and PR-relative whitespace checks passed. The private guardwords scan was skipped because its catalog was unavailable.The merge from main was clean and required no manual source changes. Existing capture, task-tool staging, cancellation and continuation behavior remains. Earlier optional KiloCode conformance failures are outside this PR; incorporated main includes a later KiloCode fix. These local results do not claim a new-head CI result.
Compatibility and limits
Defaults preserve existing behavior. Replacement and tool selection are evaluation treatments and should be recorded. OpenCode replacement selects build even if another default agent is configured; append retains custom selection. Native environment context may remain, so replacement does not promise byte-identical whole model requests.
No new dependency, runtime image, authentication or retention change. Real harness checks use synthetic local model/MCP services; no live provider, remote sandbox, benchmark-quality or full-core qualification is claimed. New source carries Apache-2.0 SPDX headers and PR commits include DCO sign-off.
Proposed maintainer labels:
feature,area:agent,needs-review.