MoonshotAI / MoonshotAI/kimi-code
不支持图片的模型在上下文压缩时因 image_url 内容报 400 错误
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
Title:
[bug] Compaction fails with image_url error on non-vision models
Body:
## Description
When using a model that does not support images (e.g. some custom models without vision capabilities), the context compaction pipeline sends `image_url` type
content in the messages, causing a 400 error from the API provider.
## Steps to Reproduce
1. Configure a model that does not support image input
2. Have a conversation where images appear (auto-detected by tools)
3. Trigger context compaction (or continue the conversation)
## Error
[compaction.failed] APIStatusError: 400 Error from provider:
Upstream request failed: [invalid_request_error] Failed to deserialize the JSON body into the target type: messages[124]: unknown variant image_url, expected text
at line 1 column 811568
## Expected Behavior
Before sending API requests, Kimi Code should detect whether the target model supports image input. If not, `image_url` type content should be filtered out or
converted to plain text descriptions.
## Environment
- Kimi Code CLI: latest version
- Model: custom non-vision model
- OS: Windows
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the context compaction pipeline and the API request message construction. Reproduce the failure with a custom non-vision model and a conversation containing images, then verify that requests no longer send unsupported image_url content and that compaction succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100