Skip to content

[FEATURE]: Code Mode execute should return images/attachments to the model #55072

Open

Description

@remorses

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

A tool that returns an image (screenshot, chart, etc.) called inside Code Mode execute only gives text back to the model. To see the image, the agent needs a second call with the normal tool (e.g. read). That costs two round trips for one action.

Proposal

Let execute forward image/file attachments from nested tool results into the execute result, so the model sees them in the same call. Also allow returning an image explicitly from the script, so a script can pick which images to show.

const shot = await tools.browser.screenshot({ url })
return shot // image shows up in the model context

Related: #55087 (built-in tools like shell in Code Mode).

Activity

  1. opencode-agent commented on Oct 13, 2026

    @opencode-agent
    Contributor

    Thanks for the suggestion! You're asking for images and other attachments from tools called inside Code Mode execute to reach the model in the same call, plus a way for a script to return or pick specific images explicitly.

    On current v2 (e.g. 2.0.27), part of this already works. execute collects file attachments from nested tool calls and passes them to the model with its result. It only does this when the tool returns the attachment as a base64 data: URI, which is what MCP image content and read produce. Attachments given as https: or file: URIs are currently dropped (see #47458). If you're on v2 and a screenshot tool still only gives back text, could you tell us which tool it is (MCP server or plugin) and your opencode --version?

    There's no way yet for a script to return an image explicitly or choose which collected images are shown; every nested attachment is forwarded. As a partial workaround, a script can call tools.read({ path }) on a saved image to put it in the result. Maintainers will consider the explicit-return and selection part.

    Related issues:

  2. remorses commented on Oct 13, 2026

    @remorses
    ContributorAuthor

    My use case is to use a bash cli to screenshot and add that image into the context in one tool call. Now it requires two, adding support for a method read into the js context would allow this to be done faster

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions