Skip to content

fix: prepare messages for non-vision model in provider profile code path (#23733)#23904

Closed
LiWeny16 wants to merge 1 commit into
NousResearch:mainfrom
LiWeny16:fix/23733-image-routing-profile-path
Closed

fix: prepare messages for non-vision model in provider profile code path (#23733)#23904
LiWeny16 wants to merge 1 commit into
NousResearch:mainfrom
LiWeny16:fix/23733-image-routing-profile-path

Conversation

@LiWeny16

Copy link
Copy Markdown

Summary

When routing through a provider profile (non-legacy path), the code skips the _prepare_messages_for_non_vision_model transformation that the legacy path applies. This causes image-containing messages to be passed unmodified to models that do not support vision, leading to crashes or incorrect behavior.

Root cause

The provider profile branch of the routing logic was missing the _prepare_messages_for_non_vision_model(api_messages) call that the legacy branch already performed.

Fix

Added _msgs_for_profile = self._prepare_messages_for_non_vision_model(api_messages) in the profile path and used messages=_msgs_for_profile instead of messages=api_messages when calling the model.

Fixes #23733

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists duplicate This issue or pull request already exists labels May 11, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #23743 — same non-vision model image stripping fix on provider profile path. This PR bundles 3 unrelated fixes (identical diff to #23905 and #23903) from a stacked branch.

…le path

The provider-profile branch of _build_chat_kwargs was forwarding raw
image_url parts to text-only models, causing HTTP 400 errors. The
legacy branch already handled this via _prepare_messages_for_non_vision_model
but the profile branch bypassed it.

Now both paths strip image parts before sending to non-vision providers.

Fixes: NousResearch#23733
@LiWeny16 LiWeny16 force-pushed the fix/23733-image-routing-profile-path branch from 305feb8 to 4677f5f Compare May 11, 2026 17:44
@LiWeny16

Copy link
Copy Markdown
Author

Thanks for the review. I've rebuilt the branches from latest main — each PR now contains only its single targeted fix instead of stacked commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: image routing bypassed on api_server /v1/chat/completions — non-vision models receive raw image_url (400)

2 participants