Declare modalities so image input actually reaches the model#1
Open
untilhamza wants to merge 1 commit into
Open
Declare modalities so image input actually reaches the model#1untilhamza wants to merge 1 commit into
untilhamza wants to merge 1 commit into
Conversation
`toConfigModel` set `attachment`, but OpenCode gates what it will actually send on `modalities.input`, which defaults to text-only. An image-capable model therefore had its attachments dropped before the request was built, and replied that it could not read images — while `opencode models kimi-code --verbose` reported `attachment: true` alongside `input.image: false`, making the mismatch easy to miss. Kimi's /models reports supports_image_in and supports_video_in for k3 and both coding models, and the API accepts image parts on the subscription endpoint — so this was purely a registration gap. - map supports_image_in/supports_video_in into modalities.input - fix STATIC_MODELS, which omitted both flags: on a cold cache (fresh install, or logged out) every model registered as text-only regardless - cover both in unit tests Verified against opencode 1.18.3: `input.image` now resolves true from both the cache and the static baseline, and k3 reads an attached PNG.
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.
The bug
Attaching an image to a Kimi model in OpenCode does nothing — the model replies that it can't read images, even though k3 and both coding models support vision.
toConfigModelsetsattachment, but OpenCode gates what it will actually send onmodalities.input, which defaults to text-only. The attachment is dropped before the request is built, so the model never sees it.This is easy to miss because the two disagree in the same output:
I confirmed this isn't upstream-side — Kimi's
/modelsreportssupports_image_in: truefor all three models, and POSTing animage_urlpart directly toapi.kimi.com/coding/v1/chat/completionsreturns a correct reading of the image. It's purely a registration gap.Changes
toConfigModel— mapsupports_image_in/supports_video_inintomodalities.inputalongside the existingattachmentflag.STATIC_MODELS— the baseline omitted both flags, so on a cold cache (fresh install, or logged out) every model registered as text-only regardless of the first fix. Added them to match what/modelsreports.Verification
Against opencode 1.18.3, with no user config override:
input.imageresolvestruefrom the cache path and the static-baseline path (tested by movingmodels.jsonaside)npm run ciclean — lint, format, typecheck, 38/38 testsNote on the
videomodalityI mapped
supports_video_infaithfully since/modelsreports it andvideois a valid literal in OpenCode's schema, but I've only exercised the image path. Happy to drop video to image-only if you'd rather not advertise something untested.