Skip to content

docs(agent): explain how to add image support to a harness - #5868

Open
yaoyu-33 wants to merge 10 commits into
mainfrom
docs/multimodal-harness-guide
Open

yaoyu-33 wants to merge 10 commits into
mainfrom
docs/multimodal-harness-guide

Conversation

@yaoyu-33

@yaoyu-33 yaoyu-33 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

The harness guide does not say how an adapter supports images. The pieces exist now (prompt media in #4917 and #4922, both merged; Pi sessions in #4923; tool-reply images and OpenCode image settings in #5719, the capture fix in #5833), but someone adding a multimodal harness has to piece the contract together from the code. This PR writes it down.

Harness guide (add-or-update-a-harness.mdx): a new "Support images" section

  • The three sources of images in an episode (task prompt, Resources Server tool reply, the harness's own tools), with a diagram and a table of what each current adapter does. The table marks opencode_sandboxed_agent as deprecated (add image support to opencode_agent), and prompt images in the Codex, Hermes, OpenClaw and Kilo adapters as to-do.
  • Prompt images, from feat: binary sandbox files and shared media helpers #4917 (shared helpers), feat(opencode): attach prompt images in agent sessions #4922 (OpenCode sessions) and feat(pi): attach prompt images in agent sessions #4923 (Pi sessions):
    • The pipeline: split_text_and_media() → 422 on UnsupportedContentError → stage_media() → the harness's attachment syntax (OpenCode --file), with images accepted only where the harness can place them.
    • How MediaFile reads a file's type from its bytes.
    • Why stage_media() names files by content (/tmp/nemo-gym-media/<sha256>.<ext>, media_path()): renamed into place atomically, and left in a borrowed sandbox after close.
    • Decoding once per activation request, and staging inside the activation's execution so close can cancel it.
    • bytes in SandboxSpec.files, and upload_bytes() / download_bytes().
    • OpenCode (--file) and Pi (@<path>) as the reference adapters, with where each puts the images and Pi's resizing, which the Pi adapter turns off (images.autoResize: false).
    • Staging under the activation's deadline (OpenCode and Pi start a first activation's budget once it holds a concurrency slot), and passing SandboxUnavailableError / SandboxTransferError through unchanged.
  • Tool-reply images: ToolOutputImage entries (checked as prompt images are, with an optional label before each image), tool_output_images over mcp (MCP image content, and why structuredContent is left out) and direct_http (split_tool_output_images(), as simple_agent does). Where the image lands in the model request decides whether vllm_model needs inline_tool_output_images: true.
  • Declare image input: why a harness needs a vision declaration (OpenCode modalities.input), why to declare it only when the episode can carry images (a text-only model refuses images that the harness's own tools open), how OpenCode and Pi follow that rule (images in the prompt or image_input: true; OpenCode keeps it for later activations), and turning off the harness's own resizing (OpenCode attachment.image).
  • Training and trajectories: tool images between calls, history edits that break capture chains, what saved trajectories keep, and the Harbor Environment Server's text-only ATIF export, which masks a turn whose response holds image parts (feat(trajectory): export image content parts to ATIF instead of failing the export #5871).
  • One new Images item in "Runtime and compatibility".

add-harness skill: a Step 0 scoping item (does the pairing carry images?), a Step 1 checklist item that points to #4917, #4922 and #4923 as the reference, Step 2 tests (including identical retries and close during staging), a Step 5 real-run check (a vision model plus a text-only control run), a Step 6 training note linking #5833 and #5837, image support in the Step 7 catalog row, and trigger words in the description.

Stack

Based on main. #4917, #4922, #5719 and #5833 are merged, so this PR holds only the two docs files. Merge after #4923 and #5960 (draft); the adapter table's Pi row describes #4923 and its Hermes row describes #5960.

The adapter table states today's behavior:

With #5833 merged, the training section now says token capture keeps OpenCode's step-limit note chained, instead of saying opencode_agent refuses agent.build.steps under token capture.

The guide recommends this rule: declare image input only for episodes that can carry images, turned on by configuration where the request cannot show it (Harbor's images are files in the task sandbox).

Validation

  • Docs and skill only; no code changes.
  • pre-commit run --files on both files: passed (guardwords included).
  • pytest tests/unit_tests/agents/test_skills.py tests/unit_tests/test_fern_docs_links.py: 53 passed (24 subtests).
  • Checked that every new anchor and cross-page link resolves to an existing heading (#support-images, #prompt-images, #tool-reply-images, #declare-image-input, mcp-resources-server#return-images-from-a-tool, vllm#vllmmodel-configuration-reference).
  • fern check was not run locally; CI runs it.

Rollouts

Documentation only. The prompt-image behavior it describes was checked with a real vision model (Qwen3-VL-8B-Instruct on vLLM) on circle_count, 5 tasks × 2 repeats per harness, each agent in its own Enroot sandbox: OpenCode on main 7c79b15, and Pi on #4923 e182553 merged with that main. Both graded 10/10 rollouts, with the same /tmp/nemo-gym-media/<sha256>.png path on every repeat of a task. Text-only rows declared no image input. A remote image URL returned 422. A 2400 px image reached the model unresized under both harnesses. Tool-reply images (#5719) were not part of that run.

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs.
  • Tests: N/A, docs-only.
  • Documentation added or updated.
  • Pre-commit checks pass on the changed files.
  • No new source files.
  • All commits have DCO sign-off (git commit -s).

🤖 Generated with Claude Code

@copy-pr-bot

copy-pr-bot Bot commented Nov 9, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@yaoyu-33 yaoyu-33 added docs Documentation-only updates or documentation debt area:docs Generic documentation without another dominant domain area:agent Agent harnesses and Responses API agent behavior labels Nov 9, 2026
@yaoyu-33

yaoyu-33 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 50f8872

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

@yaoyu-33
yaoyu-33 marked this pull request as ready for review November 9, 2026 18:37
@yaoyu-33

yaoyu-33 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Checked Harbor against this guide and pushed dbacfa0:

  • Declare image input: Harbor instructions are text, and the images are files in the task sandbox. So the rule is now "the prompt has images, the granted tools return them, or the task's files hold images the model must look at", and the last two are turned on by configuration.
  • Training and trajectories: the Harbor Environment Server exports the turn's transcript to ATIF with transcript_to_atif(), which keeps text only. An image part in the response output masks the turn as harbor:trajectory_export_failed. Verified by running the exporter on a transcript with a tool image sent as a user message. The real-run checks (guide and add-harness Step 5) now say to look for that mask on Harbor pairings.

Matching comment on #5719 about its image_input and simple_agent tool-image paths.

@yaoyu-33

yaoyu-33 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test dbacfa0

@yaoyu-33

yaoyu-33 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

The ATIF text-only limit this guide describes is tracked in #5871; the Harbor note can go once it lands.

@yfw
yfw force-pushed the yifuw/multi-harness-core branch from 728cae8 to 1686209 Compare November 9, 2026 18:53
@yfw
yfw requested a review from a team as a code owner November 9, 2026 18:53
@yaoyu-33
yaoyu-33 force-pushed the docs/multimodal-harness-guide branch from dbacfa0 to 665c432 Compare November 9, 2026 19:02
@yaoyu-33

yaoyu-33 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 665c432

Base automatically changed from yifuw/multi-harness-core to main November 10, 2026 07:12
yaoyu-33 and others added 8 commits November 10, 2026 09:29
Add a "Support images" section to the harness guide: the three places an
episode's images come from (task prompt, Resources Server tool reply, the
harness's own tools), how an adapter decodes and stages prompt images, how
tool-reply images travel over MCP and direct HTTP, when to declare image
input on the harness's model, the Model Server setting for images inside
tool outputs, and what training and trajectories need. The add-harness
skill gains the matching scoping step, checklist item, tests, real-run
checks and catalog entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
Harbor task instructions are text and their images are files in the task
sandbox, so image input has to be turned on by configuration rather than
inferred from the prompt. The Harbor Environment Server exports the turn's
transcript to ATIF with text only, so an image part in the response output
masks the turn as harbor:trajectory_export_failed; say so in the guide and
the add-harness skill, and check for it in real Harbor runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
Fold in what #4917 (shared media decoding and staging) and #4922 (OpenCode
session images) settle: how MediaFile decides a file's type, why
stage_media names files by content, why staged files survive close in a
borrowed sandbox, decoding once per activation request, staging inside
the activation's execution so close can cancel it, SandboxSpec.files bytes
for startup files, and OpenCode's _session_input and stage_activation as
the reference adapter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
Pi (#4923) now takes prompt images as @path arguments, so it joins
OpenCode as a reference adapter and gets its own row in the adapter
table, with where Pi puts the images and its default resizing (which
images.autoResize turns off). From the updated #4917: who creates the
media directory, cleanup of partial files on failure, where staged files
live on providers that share the host's /tmp, and the
SandboxUnavailableError / SandboxTransferError split. Staging now has to
run under the activation's deadline, as Pi does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
…pters as to-do in the image table

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
…ounds staging

OpenCode (#4922, merged) declares image input when the prompt has images or the
agent sets image_input: true, keeps it for later activations, and starts a first
activation's budget once it holds a concurrency slot, as Pi does. MCP tool images
need the declaration, and opencode_config attachment restores image limits.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
At #4923's head, Pi declares image input only when the prompt has images or
the agent sets image_input: true, and turns off Pi's image resizing in every
session, as the EOS smoke with a vision model confirmed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
#5719 now checks each tool_output_images entry as prompt images are checked,
gives the model an optional label before each image, and reads a null list as
no images. Say so in the tool-reply section and its skill test item.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@yaoyu-33
yaoyu-33 force-pushed the docs/multimodal-harness-guide branch from 6e3ee31 to 2e27aed Compare November 10, 2026 17:29
@yaoyu-33

Copy link
Copy Markdown
Contributor Author

/ok to test 2e27aed

yaoyu-33 and others added 2 commits November 10, 2026 20:40
…pture rule

Hermes passes prompt images as ordered Chat Completions image_url parts without
staging files; give it its own row and describe that path beside the staged one.
With #5833 merged, token capture keeps OpenCode's step-limit note chained, so
opencode_agent no longer refuses agent.build.steps under token capture.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@yaoyu-33

Copy link
Copy Markdown
Contributor Author

/ok to test 149a4b6

This branch had an error being deployed

1 failed deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Agent harnesses and Responses API agent behavior area:docs Generic documentation without another dominant domain docs Documentation-only updates or documentation debt needs-review PR is ready for code review and waiting on a reviewer sla:triage-overdue Review assignment is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants