Skip to content

fix: stop silently dropping unsupported multimodal content in kosong providers - #632

Merged
7Sageer merged 2 commits into
MoonshotAI:mainfrom
7Sageer:fix/openai-tool-result-images
Jun 10, 2026
Merged

7Sageer merged 2 commits into
MoonshotAI:mainfrom
7Sageer:fix/openai-tool-result-images

Conversation

@7Sageer

@7Sageer 7Sageer commented Jun 10, 2026 •

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue — the problem is explained below.

Problem

Provider conversion layers in kosong silently discard content parts the target API cannot represent, so the model answers as if the attachment never existed:

  • OpenAI Chat Completions: tool messages only accept text. The first commit on this branch reattaches tool-result images as a follow-up user message, but audio/video in tool results still vanished entirely — an audio-only tool result (e.g. from a TTS tool) became an empty-string tool message.
  • Anthropic Messages: audio_url / video_url parts in user/assistant messages and in tool results were skipped without a trace (the API has no audio/video input type).
  • OpenAI Responses: video_url was dropped on both the user-message and tool-result paths; audio data URLs with a subtype other than mp3/wav were dropped too. With toolMessageConversion: 'extract_text', tool-result images were flattened away with no placeholder and no reattachment.

For reference, comparable agent CLIs either degrade unsupported media to placeholder text or reattach it as user input — none drop it silently.

What changed

  • openai-legacy: tool-result images are reattached as a follow-up user message (image_url is a standard Chat Completions content part). Tool-result audio/video cannot ride along — the API has no url-based audio/video part, and sending one would fail the whole request on a standard OpenAI endpoint — so the omission is noted inline in the tool message text ((audio omitted: not supported by this provider)). Shared wording constants moved to openai-common.
  • anthropic: audio/video parts degrade to a placeholder text block in user/assistant messages and inside tool_result blocks; consecutive parts of the same kind collapse into a single placeholder.
  • openai-responses: video parts and un-encodable audio degrade to placeholder input_text items on both the user-message and tool-result paths. With extract_text, tool-result media is now buffered and reattached as a single user message after each run of consecutive tool messages (all items use standard Responses input types), mirroring the chat-completions provider.

Tests that previously asserted the silent-drop behavior were inverted to assert the placeholders, with new cases covering audio-only and text+video tool results, placeholder degradation, and extract_text reattachment.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Jun 10, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fd1def6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@moonshot-ai/kosong Patch
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@7Sageer
7Sageer force-pushed the fix/openai-tool-result-images branch from ec6ea79 to fd1def6 Compare June 10, 2026 13:35
@pkg-pr-new

pkg-pr-new Bot commented Jun 10, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@fd1def6
npx https://pkg.pr.new/@moonshot-ai/kimi-code@fd1def6

commit: fd1def6

@7Sageer
7Sageer merged commit d8cdebf into MoonshotAI:main Jun 10, 2026
8 checks passed
@github-actions github-actions Bot mentioned this pull request Jun 10, 2026
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Aug 15, 2026
…providers (MoonshotAI#632)

* fix: stop silently dropping unsupported media in provider conversions

* fix: keep non-standard audio/video parts off the chat completions wire
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant