fix: keep attachment-only messages intact when skills are bound (#30045)

Sending an image or file with no typed text to a model with skills
bound replaced the (empty) message text with the list of skill names,
so the model answered with its skill catalog instead of handling the
attachment. The empty-message guard added for #24929 fired on any
empty last user text without checking for attachments.

The guard now skips the fallback when the current message carries
files, read from the user_message object the frontend sends with the
request. Attachment-only messages then go out exactly as they do on
models without skills. A bare skill selection with no attachment still
gets the fallback, so the provider 400 from #24929 stays fixed.

Request-level files were not usable as the signal: that list carries
the model's knowledge and folder files, so a bare skill selection on a
knowledge model would have gone out empty again.

Fixes #30040
This commit is contained in:
Classic298 2026-09-16 16:19:28 +02:00 committed by GitHub
parent 82da9093aa
commit 3348f68778
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2888,7 +2888,8 @@ async def process_chat_payload(request, form_data, user, metadata, model):
# that reject empty content blocks (e.g. AWS Bedrock ConverseStream).
if not prompt or not prompt.strip():
fallback = ', '.join([s.name for s in available_skills] + [s['name'] for s in terminal_skills])
if fallback:
# Attachment-only messages keep their empty text, same as on models without skills.
if fallback and not (metadata.get('user_message') or {}).get('files'):
set_last_user_message_content(fallback, form_data['messages'])
prompt = fallback
# TODO: re-enable URL extraction from prompt