Repository navigation
feat(stirrup_agent,pi_agent): Stirrup's view_image and strip_unparsed_tool_blocks, Pi's plain prompt and MCP discovery deadline - #6972
d-molinari wants to merge 7 commits into
Conversation
|
/ok to test d0bef56 |
d0bef56 to
868ea86
Compare
|
/ok to test 868ea86 |
868ea86 to
2eba6bd
Compare
|
/ok to test 2eba6bd |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE
I found three correctness risks in the opt-in paths, one required rollout-evidence gap and one documentation note. I reviewed all 16 changed files and traced their callers and downstream consumers.
RISK: Validate recorded-history mode with a real rollout
Could you add a representative real-model smoke rollout with strip_unparsed_tool_blocks: false? The PR description explicitly says that mode has not run yet. AGENTS.md requires representative rollouts for behavior-changing agent work. The earlier capture results do not exercise this option.
Record the task, model and effective recovery/compaction settings, then inspect the agent behavior, capture acceptance and verifier result. Include a turn with an unparsed tool block so the run exercises the new behavior. My loopback probes confirm exact text replay when stripping is disabled; they do not establish that the advertised training configuration works end to end.
Validation
- I relied on the observed successful CI results for
Lint check,Unit tests / Changed server tests,Unit tests / Sandbox tests,Unit tests / Server suiteand both harness conformance probes. Four core-test shards were still running in the last successful status read. The non-blocking Environment Server compliance check reports Pi's existingrun()method. Later status and job-log reads failed with HTTP 503, so I cannot claim all CI is green or provide CI test counts. - I ran focused CPU probes in
gym:main-offline, the default branch's CI image, with Python 3.13.14, Node 24.19.0 and Stirrup 0.1.12. MCP discovery deadlines, clamping and pagination behaved as intended. Stirrup probes confirmed exact unstripped text replay, image ordering and compaction handling. They also reproduced the inline findings. - I did not rerun passing CI suites or run real-model rollouts. Dependency setup completed after resolving missing packages in the review environment; these probes are not a reproduction of the locked CI environment.
Inline comments (escaped v1):
-
responses_api_agents/pi_agent/plain-prompt.mjsline 18: RISK: Preserve dates supplied by the task. Could date removal target only Pi 0.80's generated footer?DATEcurrently runs over the complete prompt, including appended and replaced instructions. The pinned Pi 1.5.2 adds no machine date, soplain_system_prompt: truedeletes a task-owned line such asCurrent date: 2020-01-01instead. I reproduced this with the published Pi 1.5.2 prompt builder in both append and replace modes. A task that supplies its own clock loses it.The adapter combines configured and request system instructions before loading this extension. Please preserve those instructions and limit deletion to positively identified harness-generated sections. Check that task dates survive append and replace modes on Pi 1.5.2, and that a legacy prompt containing both a task date and a generated date loses only the latter. Update the existing custom-prompt test, which currently expects its date to disappear.
-
responses_api_agents/stirrup_agent/sandbox_runner.pyline 214: RISK: Return recoverable file errors as failed image-tool calls. This exposes LocalShell.view_image, but Stirrup's helper catches onlyFileNotFoundErrorandValueError. A directory raisesIsADirectoryError; a file with a valid PNG signature but corrupt contents raises Pillow'sUnidentifiedImageError. Both escape the helper.I reproduced both through the runner. The corrupt-image entrypoint probe ended after one model call with
STATUS=failedandHAS_TRAJECTORY=False; sandbox execution then raises for that error. An ordinary mistaken path or malformed screenshot therefore aborts an opt-in episode instead of letting the model recover.Could the adapter translate expected path/read/decode failures into
success=Falsewith useful text and no image, while keeping cancellation and unrelated failures propagating? Add runner cases for a directory and a recognized-but-corrupt PNG. Both should permit a subsequent finish call; missing-file and valid-image behavior should stay intact. -
nemo_gym/trajectory/atif_export.pyline 1162: RISK: Image-bearing Stirrup trajectories cannot reach Harbor grading. The new _image_parts export keeps realinput_imageparts, but this downstream converter rejects them. Harbor exports before invoking its verifier and convertsAtifExportErrorinto a maskedharbor:trajectory_export_failedresult. Thus an otherwise successful Harbor episode usingview_imageskips grading. The reward-hacking judge also masks this conversion failure.A base-versus-head probe exported the same raw history successfully on base and raised
AtifExportError: only text content parts are supportedon head. Response-schema and observation validation both passed beforehand.Could this PR handle image parts at the ATIF boundary for supported pairings, or reject an unsupported pairing explicitly before activation rather than mask completed work? Keep the full image data in the Responses trajectory. Add a regression that takes an image-bearing Stirrup response through Harbor's export path and verifies that grading runs, covering initial and post-tool images.
-
responses_api_agents/stirrup_agent/app.pyline 306: NOTE, documentation suggestion: Could you documentview_imagein the Stirrup README's tool/configuration sections and the published harness guide? The new user-facing option is described in this field and the PR, but the README still lists only shell and request tools and has noview_imageentry.A minimal
view_image: trueexample should state its false default, the vision-model requirement, path handling and that it works withcode_exec: false. Document supported environment/export pairings after resolving the ATIF compatibility finding. This will make the feature usable without reading the implementation.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
…tory The runner never offered the model a way to look at an image file: LocalShell.view_image existed, but no tool used it. With view_image: true the model gets Stirrup's view_image tool on the working directory. Stirrup sends the image in a user message after the tool's text answer (text_only_tool_responses), re-encoded as a PNG of at most one megapixel. The trajectory export turned an image block into its Python repr: a tool result's list content became str(list), a user message's image part str(ImageContentBlock), and user messages added during the run went to input_items, out of order. Images are now input_image parts holding the data URL the model was sent, and user messages after the model's first turn are output items in their place. Each message list of the history counts on its own: a compaction starts a new one, whose leading user messages (the task and the summary) stay input items, so a summary is never output. Contract tests: an initial image, an image after a tool call, two ordered images (two turns and one turn), a missing file and a file that is no image, a large image downscaled, the option off, and a trajectory with images validating as a response and an observation. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]>
…rn back as the model wrote it Training on recorded tokens (token capture) needs each model call of an episode to continue the previous one as the model wrote it. context_summarization_cutoff (#6672) keeps the history from being summarized; one rewrite still had no switch: the adapter strips a tool-call block the provider's parser left in an assistant turn's text from the history sent back (stirrup_utils._strip_unparsed_tool_blocks), so the next call matches no recorded call. strip_unparsed_tool_blocks (default true, as today) is now an option of the agent server. The server passes it in the runner payload's client settings, and the model client passes it to the history serializer. The README lists it with the client options and names it beside the rewrites that stay. Tests: the payload carries the switch, and an assistant turn with an unparsed block goes back to the model as written only when stripping is off. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]>
… machine's date out of its prompt Pi's default system prompt points at Pi's own documentation by path, in the runtime's folder: /tmp/nemo-gym-pi-node-22.19.0-<version>/pi/node_modules/@earendil-works/pi-coding-agent/README.md, docs and examples. A model in a sandbox session reads the adapter's folder name on every call (three paths in each request). Pi 0.80 also ends the prompt with the machine's date, which a task that sets its own time contradicts. With plain_system_prompt on (default off), the adapter loads plain-prompt.mjs, which removes both through Pi's before_agent_start hook: the <docs> section of Pi 1.5.2's structured prompt (the default pin), or Pi 0.80's documentation block and date line. The rest of the prompt (tools, rules, the appended system prompt, the working directory) is unchanged. A prompt with neither, as under system_prompt_mode replace on Pi 1.5.2, is left to Pi: the hook returns nothing, since a returned prompt replaces Pi's structured one for the run. Sandbox sessions upload the extension with the others; local runs load it from the package. Tests: under Node, the extension's edit of Pi 1.5.2's and Pi 0.80.2's prompt layouts, a replaced prompt left alone, and a custom prompt losing only its date line. With the pinned Pi CLI and a loopback model, the request's system prompt keeps Pi's preamble, its tools and the appended prompt, and names the documentation only with the option off. A sandbox session loads the extension only when the option is on. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]>
Pi's MCP discovery (initialize, tools/list) gave up after a hard-coded 30 s, at most the tool-call timeout. A resources server busy with many other sessions can take longer to answer: in a training run with a few hundred episodes on one server, 27 of 781 Pi episodes (3.5%) failed there while the server built worlds and collected garbage on its event loop. A required grant that is not set up stops Pi before its first model call, so each such episode was lost. sandbox_mcp_discovery_timeout_seconds (default 30, as before) sets the deadline. gym_mcp.mjs reads it from the MCP configuration as discovery_timeout, and a discovery request still never waits longer than a tool call. Tests that fail on the parent: a discovery request honours discovery_timeout (a 300 ms initialize times out at 100 ms, passes at 1 s, and stays capped by the call timeout); the MCP configuration carries it; the setting stays within Node's timer range and defaults to 30 s. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]>
plain-prompt.mjs removed the first `Current date: YYYY-MM-DD` line anywhere in the system prompt. Pi 1.5.2 adds no date, so the line it removed was the task's own: a task whose appended or replacing system prompt sets its time lost it. On Pi 0.80.2 the task's line comes before Pi's, so the task's date went and the machine's stayed. Pi 0.80 ends the prompt it builds with its date line and then `Current working directory: <cwd>`. The extension now removes a date line only there: right before the working directory line, with the session's working directory from the event's systemPromptOptions, that ends the prompt. A sandbox session loads the extension before the runtime guards, which append to the prompt, so the prompt it gets ends as Pi built it. Tests that fail on the parent: under Node, on the layouts of Pi 1.5.2 and Pi 0.80.2, the task's date line stays in append and replace mode while Pi 0.80.2's own date goes, and a date line elsewhere, under another working directory or with none reported stays; with the pinned Pi 1.5.2 CLI, the task's system prompt reaches the model whole, its date line included, in both modes; a sandbox session loads plain-prompt.mjs before runtime-guards.mjs. Run over the prompts the real Pi 1.5.2 and 0.80.2 builders make, in both modes, the extension gives the same results. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]>
…ailed call Stirrup's view_image helper turns only a missing file and a file of an unsupported type into a failed call. Other errors left the tool and ended the run after that call: a directory (IsADirectoryError), a path through a file (NotADirectoryError), an unreadable file, or a file with a PNG signature that Pillow cannot read (UnidentifiedImageError, or SyntaxError for a damaged PNG). An image whose header and checksums pass Pillow's check but whose pixel data does not decode passed the call and failed in the next model request, where Stirrup encodes it, which ended the run too. A text file was a failed call whose message held the file's whole content. WorkspaceImages now runs its own view_image executor on LocalShell.view_image. The file system's errors, Stirrup's type check and Pillow's decoding errors (OSError, SyntaxError, ValueError, DecompressionBombError) are a failed call with a one-sentence answer and no image. The call encodes the image once, as each request does, so data that does not decode fails the call. A missing file keeps Stirrup's answer, and a viewed image is answered as Stirrup's tool answers it. Other errors, and a cancellation, still end the run. Tests that fail on the parent: through the runner, a directory, a path through a file, a file with only a PNG signature and a PNG whose pixel data does not decode are failed calls, after which the model's finish ends the run as completed; an 80 KB text file is answered in a sentence. A missing file keeps its answer. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]>
…no images The README listed only the shell and the request's tools, and view_image had no entry. It now has a configuration row and a "Viewing images" section: off by default and for vision models; a file named by its path in the working directory or its absolute path, with or without code_exec; what the model gets; how a file that cannot be shown is answered; and what the trajectory keeps. Gym's ATIF converter takes text content only. The section says where that stops grading: the harbor environment server masks a turn whose transcript holds an image (harbor:trajectory_export_failed) instead of running the task's verifier, the reward-hacking judge masks its verdict, and `gym eval export atif` fails on the rollout. view_image is for environments whose resources server grades the response or the sandbox. The view_image field's description says the same. Tests for what the section states: view_image with code_exec off, by a relative and by an absolute path; a Stirrup transcript without an image converts to ATIF as Harbor exports a turn, and one with an image is refused. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]>
2eba6bd to
8b57ec8
Compare
|
/ok to test 8b57ec8 |
|
Thanks for the review. Addressed in
Tests at the head before the final no-conflict rebase: |
What does this PR do?
Agent options that keep today's behaviour by default, from the drafts #5806, #5835 and #5545, rebased onto main.
context_summarization_cutoff, which this PR carried before, landed with #6672, so this PR keeps main's.Stirrup
view_image(off): the model gets Stirrup'sview_imagetool on the working directory. Stirrup sends the image after the tool's text answer, as a PNG of at most one megapixel, andimage_token_estimatecounts it.input_imageparts holding the data URL the model was sent, and main's reasoning items. User messages that Stirrup adds during a run become output items, in order. A compaction's task and summary stay input items, as on main.strip_unparsed_tool_blocks(true): off, an assistant turn with no parsed tool call goes back to the model as written, so a run that trains on recorded tokens keeps that turn too. The README names it beside the rewrites that stay under "Keeping the recorded history" (feat(stirrup_agent): stop runs once the task has ended and add an option to keep the recorded history #6672's section).Pi
plain_system_prompt(off) leaves out the part of Pi's prompt that names Pi's documentation by path, in the runtime's folder. On Pi 1.5.2, the pin, that is the<docs>section; on Pi 0.80 it is the documentation block and the date line. feat(pi_agent): plain_system_prompt, and a configurable MCP discovery deadline #5545's version matched only Pi 0.80's layout. A replaced prompt goes to the model as Pi builds it.sandbox_mcp_discovery_timeout_seconds(default 30, at most a tool call's timeout) bounds each request that sets up a sandbox session's MCP tools. At the hard-coded 30 s, a busy resources server lost 27 of 781 Pi episodes.Validation
At this head, on main
64d738eca2, Linux:responses_api_agents/stirrup_agent: 255 passed.responses_api_agents/pi_agent, with Node 22.19 and the pinned Pi 1.5.2 CLI on the path: 478 passed, 2 skipped.test_plain_prompt.pyfail.run(), whichpi_agentdefines on main too.Rollouts
All three ran before the rebase onto this main:
plain_system_prompton, gpt-5.5, five OfficeEnv tasks in Docker sandboxes (11-30): all five scored 1.0 and were stopped as completed at the task's end, with no sandbox left.view_image, from feat(stirrup_agent): add a view_image tool and keep images in the exported trajectory #5806: an episode in a vision RL lab was solved (reward 1.0), and the image's bytes matched at every hop.context_summarization_cutoff: nullnow avoids. No run yet withstrip_unparsed_tool_blocksoff.Compatibility and benchmark impact
resources_servers/officeenv_sandbox/README.mdsaying Gym's Stirrup gives the model no tool that shows it an image. Whichever of the two PRs merges second updates it.Checklist
git commit -s) (so the DCO check passes).🤖 Generated with Claude Code