Skip to content

fix(agent-core): strip unsupported media only for explicit capability matrices - #2707

Open
686f6c61 wants to merge 3 commits into
MoonshotAI:mainfrom
686f6c61:fix/2669-downgrade-media-unknown-capability
Open

fix(agent-core): strip unsupported media only for explicit capability matrices#2707
686f6c61 wants to merge 3 commits into
MoonshotAI:mainfrom
686f6c61:fix/2669-downgrade-media-unknown-capability

Conversation

@686f6c61

@686f6c61 686f6c61 commented Aug 6, 2026

Copy link
Copy Markdown

Summary

  • downgradeUnsupportedMedia must not treat UNKNOWN_CAPABILITY as text-only: that marker means uncatalogued (e.g. SingleModelProvider default) and can still represent a multimodal model.
  • Stripping remains for explicit capability matrices with image_in / video_in / audio_in false — the shape ProviderManager produces from declared config such as capabilities = ["thinking", "tool_use"].
  • Documents and locks that distinction with regression tests (Codex P1).

Related to #2669 (text-only custom providers with an explicit no-vision matrix).

Test plan

  • vitest run test/agent/kosong-llm.test.ts in packages/agent-core (18 passed)
    • preserves media for UNKNOWN_CAPABILITY
    • strips images for an explicit matrix without image_in

downgradeUnsupportedMedia previously left image/video/audio parts intact
when capability was UNKNOWN_CAPABILITY. Uncatalogued or custom
OpenAI-compatible text-only models then received history with image_url
parts, returned 400, and poisoned every subsequent turn (MoonshotAI#2669).

Honor image_in/video_in/audio_in flags for all known matrices including
UNKNOWN (all false). Only skip when capability is undefined.

Fixes MoonshotAI#2669
@changeset-bot

changeset-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5229cd2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 44969a335a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// OpenAI-compatible provider returns 400 and poisons every subsequent turn
// (#2669). UNKNOWN was previously exempt, which left custom providers that
// declare no vision (or are uncatalogued) unprotected.
if (capability === undefined) return [...messages];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve media when capabilities are genuinely unknown

When a host uses KimiForCodingProvider or constructs the public SingleModelProvider without its optional capability argument, Agent passes UNKNOWN_CAPABILITY here. That marker means the model is uncatalogued, not that it is text-only, so it can represent a multimodal custom model; this change then silently replaces every image, video, and audio part—including the current user attachment—before generate() sees it. Keep unknown capabilities distinct from explicitly unsupported modalities, or make these providers supply an accurate matrix while applying the conservative behavior only to the affected text-only configuration.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 5229cd2: UNKNOWN_CAPABILITY is left alone again (uncatalogued ≠ text-only). Stripping only runs for explicit matrices with image_in / video_in / audio_in false. Covered by preserves media for UNKNOWN_CAPABILITY and strips images when an explicit matrix has no image_in in packages/agent-core/test/agent/kosong-llm.test.ts.

Document the user-facing CLI patch for stripping unsupported media when
the model capability matrix has no media input (including uncatalogued
custom providers).
Codex review: UNKNOWN means uncatalogued, not text-only. Multimodal
custom models and SingleModelProvider defaults use that marker; stripping
would drop legitimate attachments.

Keep stripping only for explicit capability matrices with image_in /
video_in / audio_in false (ProviderManager-resolved declared caps, MoonshotAI#2669).
@686f6c61 686f6c61 changed the title fix(agent-core): strip unsupported media for UNKNOWN capabilities fix(agent-core): strip unsupported media only for explicit capability matrices Aug 6, 2026
@686f6c61

686f6c61 commented Aug 6, 2026

Copy link
Copy Markdown
Author

Codex P1 addressed (5229cd2)

Agreed with the review: UNKNOWN_CAPABILITY is left alone again — uncatalogued ≠ text-only (SingleModelProvider defaults / multimodal custom models).

Stripping still applies only to explicit matrices with image_in / video_in / audio_in false (what ProviderManager builds from declared capabilities = ["thinking", "tool_use"] without the UNKNOWN marker).

Also dropped the changeset — this is a behavioral guard + tests, not a user-facing CLI changelog entry on its own.

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