{"record":{"id":"ef7d64ce5119a27f","repo":"zed-industries/zed","slug":"attempted-to-read-an-image-but-this-model-doesn-t","errorCode":null,"errorMessage":"Attempted to read an image, but this model doesn't support it.","messagePattern":"Attempted to read an image, but this model doesn't support it\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent/src/thread.rs","lineNumber":3646,"sourceCode":"                        let placeholder = LanguageModelToolResultContent::Text(Arc::from(\n                            \"[Tool responded with an image, but this model doesn't support images]\",\n                        ));\n                        let has_non_image = output\n                            .llm_output\n                            .iter()\n                            .any(|part| !matches!(part, LanguageModelToolResultContent::Image(_)));\n                        if has_non_image {\n                            output.llm_output = output\n                                .llm_output\n                                .into_iter()\n                                .map(|part| match part {\n                                    LanguageModelToolResultContent::Image(_) => placeholder.clone(),\n                                    other => other,\n                                })\n                                .collect();\n                            (false, output)\n                        } else {\n                            let output = anyhow::anyhow!(\n                                \"Attempted to read an image, but this model doesn't support it.\",\n                            )\n                            .into();\n                            (true, output)\n                        }\n                    } else {\n                        (false, output)\n                    }\n                }\n                Err(output) => (true, output),\n            };\n\n            (\n                owning_message_ix,\n                LanguageModelToolResult {\n                    tool_use_id,\n                    tool_name,\n                    is_error,","sourceCodeStart":3628,"sourceCodeEnd":3664,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/agent/src/thread.rs#L3628-L3664","documentation":"When a tool result contains image content and the active model cannot accept images in tool results, the thread replaces image parts with a placeholder if any non-image content exists; if the output consists solely of images, the result is converted into this error. It prevents sending an unsupported image-only payload to the model.","triggerScenarios":"A tool whose output is only LanguageModelToolResultContent::Image parts (for example reading or capturing an image) runs while the turn's model has no image input support, or an errored tool output carried image-only content.","commonSituations":"Using image-reading or screenshot tools with a text-only model; the model being switched mid-session to one without vision; a subagent configured with a text-only model invoking an image tool.","solutions":["Switch the thread to a model that supports image input and resend","Make the tool return textual context (dimensions, path, OCR text) alongside or instead of the raw image","Restrict image-returning tools so they are only offered to image-capable models","Handle the error as a tool outcome and let the agent continue with a textual explanation"],"exampleFix":"// before: tool returns only an image\nOk(vec![LanguageModelToolResultContent::Image(image)])\n\n// after: always pair the image with text so non-vision models keep working\nOk(vec![\n    LanguageModelToolResultContent::Text(format!(\"image {}x{} at {}\", width, height, path)),\n    LanguageModelToolResultContent::Image(image),\n])","handlingStrategy":"validation","validationCode":"// In the tool: avoid returning image-only output when the model lacks vision.\nfn safe_output(\n    output: Vec<LanguageModelToolResultContent>,\n    model_supports_images: bool,\n) -> Vec<LanguageModelToolResultContent> {\n    if model_supports_images {\n        return output;\n    }\n    output\n        .into_iter()\n        .map(|part| match part {\n            LanguageModelToolResultContent::Image(_) => {\n                LanguageModelToolResultContent::Text(\"[image omitted]\".into())\n            }\n            other => other,\n        })\n        .collect()\n}","typeGuard":"fn is_image_only_output(output: &ToolRpcOutput) -> bool {\n    !output.llm_output.is_empty()\n        && output\n            .llm_output\n            .iter()\n            .all(|part| matches!(part, LanguageModelToolResultContent::Image(_)))\n}","tryCatchPattern":"match tool_result {\n    Err(err) if err.to_string().starts_with(\"Attempted to read an image\") => {\n        // Degrade gracefully: tell the agent the model cannot see images.\n        report_to_model(\"This model cannot view images; describe them in text instead.\");\n    }\n    other => other,\n}","preventionTips":["Check the model's image-input capability before offering image-returning tools","Always include textual context next to image parts in tool outputs","Switch to a vision-capable model before using screenshot or read-image tools","Re-check capabilities after switching models mid-session"],"tags":["rust","agent","tools","images","multimodal","model-capabilities"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}