Repository navigation
fix: return images read on a held Run as ReadSuccess.data - #42
Merged
Merged
Conversation
nkoynov
force-pushed
the
fix/read-image-results
branch
from
October 5, 2026 18:17
c6063b8 to
69ba35e
Compare
Owner
CONTRIBUTING checklistPer CONTRIBUTING.md, please add:
Live before/after and CHANGELOG look good. |
Contributor
Author
|
Closing per the new contribution policy. This fix and the others we had open are maintained in our fork: https://github.com/nkoynov/cursor-opencode-provider |
Owner
|
Reopening to land a quality-standard rebase onto current |
When the model reads an image with OpenCode's `read` tool, OpenCode answers with "Image read successfully" and moves the image into a trailing `Attached media from tool result:` user message (third-party providers are not on its media-in-tool-result allowlist). The provider skipped that message when locating the live tool results and encoded the read as text, so the model got only the placeholder and saw the image, if at all, as a history image on the next user turn. Models then guessed or fell back to decoding the file in the shell. Cursor's own read executor answers an image file with its bytes in `ReadSuccess.data` (oakimov#5, already declared in messages.ts) and no text. Do the same on held-Run continuations: keep the media parts of the trailing message (and a result's own `file-data` parts) and attribute them in result order. One result takes all of them; with several, each media read ("Image read successfully") takes one part, results OpenCode replaced with "Media attached in the following user message." take the rest, and media no placeholder settles rides on the last result, as host notes already do. Decode them with the existing image-input helpers and encode a successful `read_result` with `data` instead of `content`. Delivered images are added to the session's sent history-image hashes so the next fresh Run does not attach them again. Results without an image field keep the existing history path; models without image support are unchanged.
oakimov
force-pushed
the
fix/read-image-results
branch
from
October 7, 2026 23:28
69ba35e to
37a7810
Compare
Owner
|
CONTRIBUTING checklist (tip 37a7810):
Live A/B: OC1.18.35 + OC2.0.24 pass ( |
nkoynov
added a commit
to nkoynov/cursor-opencode-provider
that referenced
this pull request
Oct 8, 2026
Fork main moved past b88509f while the upstream sync was prepared: CP-39's early tool rows (46b51e7, 200f132, 04ab323, 9ed6eff). The tool-call id of an early row now resolves in correlateToolResults, where the merged oakimov#42 code correlates results after attributing detached media. Its CHANGELOG entry goes under [Unreleased].
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.
When the model reads an image with OpenCode's
readtool, OpenCode answers with "Image read successfully" and moves the image into a trailingAttached media from tool result:user message (third-party providers are not on its media-in-tool-result allowlist). The provider skipped that message forliveTailand encoded the read as text, so the model saw only the placeholder on that turn.Cursor's own read executor answers an image file with bytes in
ReadSuccess.data(#5) and no text (LocalReadExecutorin the Cursor CLI local unpack). This PR does the same on held-Run continuations.Changes
<system-update>append and<system-reminder>skipurlas well asdatafor OpenCode 1); gate onsession.supportsImagesread_resultwithdata,total_lines: 0,file_sizefrom bytes when path stat failsreference_image_pathsuse the sameReadSuccess.datapath; no CLI resize (20 MiB decode budget); PDF not delivered;cursor_image_save/ write path unchangedDependency note
GenerateImage output write /
cursor_image_saveis independent. This PR only unlocks reference reads viaReadSuccess.data. No image-save code changes.Stacked: #46 builds on this.
Tests
tools.test.ts,image-input.test.ts(OC1 data-URL + OC2 base64),continuation-session.test.ts(attribution, plan-reminder+caption, delivery, hash-after-success)bun test/typecheck/build/ architecture gate greenLive A/B + cache (quality bar)
continuation: 1 tool-result image(s) on read_result; prompt "open shot.png…"continuity=warm, ~99%rawReadVsPriorContexton both hostsreference_image_pathsmuse-spark-1.3) — ref read viaread_resultimage path, then existingcursor_image_savelanded outputMethod: automated
opencode runagainst localdist/(not interactive TTY). Image-save untouched.CONTRIBUTING checklist
[Unreleased]Fixed + credit @nkoynov