Repository navigation
feat(stirrup_agent): add a view_image tool and keep images in the exported trajectory - #5806
Closed
d-molinari wants to merge 1 commit into
Closed
d-molinari wants to merge 1 commit into
d-molinari wants to merge 1 commit into
Conversation
…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. 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]>
7 tasks done
Contributor
Author
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.
What does this PR do?
Lets a Stirrup run show the model an image file from its workspace, and keeps images in the trajectory Gym exports.
view_image(new option, off by default). The in-sandbox runner never offered a tool that reads an image:LocalShell.view_imageexisted, but nothing used it. Withview_image: true, the model gets Stirrup's ownview_imagetool on the working directory. Stirrup answers with 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. A missing file, or one that is not an image, is a failed call that says why, and no image reaches the model.The trajectory export (
convert_stirrup_history_to_output_items) lost images, and reordered messages:str(list), so an image block turned into its Python repr.input_imagebecamestr(ImageContentBlock).view_imagecall, a turn warning) left their place in the conversation.Now:
input_imagepart holding the data URL the model was sent (the sameto_base64_urlcall, so the same bytes).Validation
tests/test_images.py(9 tests) covers:view_imagecall;gym env test +entrypoint=responses_api_agents/stirrup_agent: 185 passed (176 before this PR, plus the 9 new).pre-commitanddetect-secretspass on the changed files, and the commit is signed off.Rollouts
One episode in a vision RL lab, with a vision-language policy served by NeMo RL's vLLM worker. Stirrup ran in a Docker sandbox, and the task needed an image the episode saved in the workspace. The model called
view_imageand solved the task (reward 1.0). The image's bytes matched at every hop: Stirrup's re-encode of the file, each model call afterview_image, the trajectory'sinput_image, and the pixels in NeMo RL's training row.Compatibility and benchmark impact
view_imagedefaults to off, so the model's tools are unchanged unless a config turns it on.Checklist
git commit -s).🤖 Generated with Claude Code