@@ -281,12 +281,17 @@ def _start_agent(
281281 # ImagePart attachments, text files become TextPart attachments.
282282 # The @path token is stripped from the text (the content lives
283283 # in the attachment), and validation errors are shown to the user.
284+ has_images = False
284285 if isinstance (text , Message ):
285286 user_msg = text
286287 cleaned_text = text .text ()
287288 attachments : list [Any ] = []
288289 errors : list [Any ] = []
289290 display_text = cleaned_text .strip () or "(attachment)"
291+ has_images = (
292+ isinstance (text .content , list )
293+ and any (isinstance (p , ImagePart ) for p in text .content )
294+ )
290295 else :
291296 cleaned_text , attachments , errors = parse_at_references (
292297 text , str (self .session .project_dir )
@@ -327,7 +332,10 @@ def _start_agent(
327332 # will be silently stripped before the request is sent (see
328333 # Client._payload), so the user should know the image never
329334 # reaches the model.
330- if attachments and any (isinstance (a .part , ImagePart ) for a in attachments ):
335+ has_image_parts = has_images or (
336+ attachments and any (isinstance (a .part , ImagePart ) for a in attachments )
337+ )
338+ if has_image_parts :
331339 from ..config import get_model_info
332340
333341 # A malformed image_input_models config must not break the
0 commit comments