Skip to content

server: accept OpenAI tool-role inline images - #934

Open
aj-img wants to merge 1 commit into
antirez:mainfrom
aj-img:server-tool-role-images
Open

server: accept OpenAI tool-role inline images#934
aj-img wants to merge 1 commit into
antirez:mainfrom
aj-img:server-tool-role-images

Conversation

@aj-img

@aj-img aj-img commented Sep 1, 2026

Copy link
Copy Markdown

Fixes #933.

ds4-server returned 400 "invalid JSON request" for valid OpenAI Chat Completions bodies that put an inline PNG/JPEG data URI on role=tool (or role=function). That is the normal shape for OpenAI-compatible agents attaching a tool-result screenshot. The same data URI on role=user already worked.

This change allows images on user, tool, and function. 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

./ds4_test --server

Server tests pass, including the new tool-role parser case and the existing path/URL rejection cases.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ds4-server 400s valid OpenAI tool-role image messages as invalid JSON

1 participant