server: accept OpenAI tool-role inline images - #934
Open
aj-img wants to merge 1 commit into
Open
Conversation
OpenAI-compatible agents attach vision inputs on role=tool (and the legacy role=function). ds4-server treated that as a parse failure and returned 400 "invalid JSON request" even when the body was valid JSON with a png/jpeg data URI. Allow images on user, tool, and function messages. Keep rejecting assistant/system images, file paths, and remote URLs. DeepSeek already wraps tool results in a user turn; add a parser unit test for the tool-role shape.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #933.
ds4-serverreturned 400"invalid JSON request"for valid OpenAI Chat Completions bodies that put an inline PNG/JPEG data URI onrole=tool(orrole=function). That is the normal shape for OpenAI-compatible agents attaching a tool-result screenshot. The same data URI onrole=useralready worked.This change allows images on
user,tool, andfunction. Assistant and system images, file paths, and remote URLs stay rejected. DeepSeek already wraps tool results in a user turn, so the image markers still land on a user-shaped span.Also documents the accepted roles and adds
test_openai_tool_role_inline_image.Test
Server tests pass, including the new tool-role parser case and the existing path/URL rejection cases.