Skip to content

fix(opencode): Fixes image reading with OpenAI-compatible providers like Kimi K2.5.#11323

Merged
rekram1-node merged 4 commits intoanomalyco:devfrom
zhming0:ming/fix-11304
Feb 5, 2026
Merged

fix(opencode): Fixes image reading with OpenAI-compatible providers like Kimi K2.5.#11323
rekram1-node merged 4 commits intoanomalyco:devfrom
zhming0:ming/fix-11304

Conversation

@zhming0
Copy link
Copy Markdown
Contributor

@zhming0 zhming0 commented Jan 30, 2026

What does this PR do?

Fixes #11304.
Fixes #11306.
Fixes #11550.

Problem: When using the Read tool to read an image file, Claude works fine but OpenAI-compatible providers (Kimi, etc.) fail to see the actual image content. The model either dumps base64 data as text or hallucinates the image content.

Root cause: OpenAI-compatible Chat Completions API only supports string content in tool results. When the Read tool returns an image as an attachment, it gets JSON.stringify()'d and the model can't interpret it as an image.

Solution: For providers using @ai-sdk/openai-compatible SDK that support image input:

  • Extract media (images, PDFs) from tool results
  • Inject them as a synthetic user message after the assistant message
  • The model then sees the media as user-provided content, which is supported

How did you verify your code works?

  1. Tested with Kimi K2.5 - asked it to read /tmp/test.png (a dashboard screenshot)
  2. Before fix: Model dumped base64 or hallucinated "Hello World" text
  3. After fix: Model correctly described the dashboard UI with "Explore", "Dashboards", "Monitors" etc.
Screenshot 2026-01-31 at 1 41 41 am

@github-actions
Copy link
Copy Markdown
Contributor

Hey! Your PR title Fixes image reading with OpenAI-compatible providers like Kimi K2.5. doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@zhming0 zhming0 changed the title Fixes image reading with OpenAI-compatible providers like Kimi K2.5. fix(opencode): Fixes image reading with OpenAI-compatible providers like Kimi K2.5. Jan 30, 2026
@zhming0 zhming0 mentioned this pull request Jan 30, 2026
1 task
@rekram1-node
Copy link
Copy Markdown
Collaborator

Will look tmr, there is some granularity with other providers and packages, need to verify that this properly fixes all the providers

Some have special cases like good for example, u can send attachments as tool results for the gemini-3 series models but no others

@robinr2
Copy link
Copy Markdown

robinr2 commented Feb 4, 2026

I have the same issue but I am using Opus 4.5 via Google/Antigravity and Copilot providers. It works with some other models of these two providers. Claude models can't read images using the Read tool.

Also tested it with this branch. Doesn't fix the issue for me.

@rekram1-node
Copy link
Copy Markdown
Collaborator

The copilot one makes sense why it'd have an issue, Ik how to fix w/ this branch, for antigravity im not really sure

@rekram1-node
Copy link
Copy Markdown
Collaborator

Okay I tested various providers, it should work fine now. Also added a text part too (some providers are more strict about that than others)

@rekram1-node rekram1-node merged commit 72de9fe into anomalyco:dev Feb 5, 2026
4 checks passed
@rekram1-node
Copy link
Copy Markdown
Collaborator

/review

Colin4k1024 pushed a commit to Colin4k1024/opencode that referenced this pull request Feb 10, 2026
…ike Kimi K2.5. (anomalyco#11323)

Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
schneiderlo pushed a commit to schneiderlo/opencode that referenced this pull request Feb 17, 2026
…ike Kimi K2.5. (anomalyco#11323)

Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
avion23 pushed a commit to avion23/opencode that referenced this pull request Mar 4, 2026
…ike Kimi K2.5. (anomalyco#11323)

Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants