-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Bug: Image paste fails with 'prompt is empty' error (Windows) #2535
Description
Bug Report: Image paste fails with "prompt is empty" error
Description
When pasting an image using Ctrl+V in Crush, the image is correctly displayed as an attachment (e.g., paste_1.png), but pressing Enter to send results in an error: ERROR prompt is empty
This prevents users from sending images without accompanying text, even when the model supports image attachments or when MCP tools are configured to handle images.
Root Cause
There are 4 layers of validation that reject image-only messages:
1. UI Layer (internal/ui/model/ui.go:1757)
if len(value) == 0 && !message.ContainsTextAttachment(attachments) {
return nil
}Checks if message is empty AND contains no text attachments. Images are not text attachments, so this rejects image-only messages.
2. Agent Layer (internal/agent/agent.go:159)
if call.Prompt == "" && !message.ContainsTextAttachment(call.Attachments) {
return nil, ErrEmptyPrompt
}Same issue - only checks for text attachments.
3. Image Filtering (internal/agent/coordinator.go:152-161)
if !model.CatwalkCfg.SupportsImages && attachments != nil {
// filter out image attachments
filteredAttachments := make([]message.Attachment, 0, len(attachments))
for _, att := range attachments {
if att.IsText() {
filteredAttachments = append(filteredAttachments, att)
}
}
attachments = filteredAttachments
}Removes image attachments when the model reports SupportsImages: false, even when MCP tools are configured to handle images.
4. Empty Prompt Validation
Some API layers (Fantasy library or Anthropic API) reject empty prompts even when attachments are present.
Platform Affected
- Windows - Primary issue due to clipboard handling differences
- Likely affects other platforms with similar attachment validation logic
Solution
Fix 1: Update UI Layer Validation
Change attachment check to accept ANY attachment type (not just text):
// internal/ui/model/ui.go:1757
if len(value) == 0 && len(attachments) == 0 {
return nil
}Fix 2: Update Agent Layer Validation
Same fix in agent layer:
// internal/agent/agent.go:159
if call.Prompt == "" && len(call.Attachments) == 0 {
return nil, ErrEmptyPrompt
}Fix 3: Skip Image Filtering for MCP-Enabled Providers
Add provider-specific filtering to allow images when MCP tools handle them:
// internal/agent/coordinator.go:154
if !model.CatwalkCfg.SupportsImages && model.ModelCfg.Provider != "minimax-china" && attachments != nil {
// filter out image attachments
...
}Fix 4: Add Default Prompt for Attachment-Only Messages
When prompt is empty but attachments exist, add a default prompt:
// internal/agent/coordinator.go:138
func (c *coordinator) Run(ctx context.Context, sessionID string, prompt string, attachments ...message.Attachment) (*fantasy.AgentResult, error) {
// If prompt is empty but there are attachments, use a default prompt
if prompt == "" && len(attachments) > 0 {
prompt = "Please analyze the image/attachment I sent"
}
...
}Environment
- Crush version: v0.53.1
- OS: Windows 11
- Terminal: Windows Terminal / WezTerm
- Model: MiniMax-M2.7 (with MCP image processing configured)
Additional Context
The issue is particularly problematic for users who:
- Want to quickly share images without typing text
- Use MCP tools to process images (e.g., vision analysis, OCR)
- Configure providers that may report
SupportsImages: falsebut have MCP tools to handle images
The current validation logic assumes that if a model doesn't natively support images, images should be filtered out. However, this breaks the MCP workflow where the MCP tool itself handles image processing.