Skip to content

不支持图片的模型在上下文压缩时因 image_url 内容报 400 错误 #2759

Description

@countryless

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 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions