Skip to content

Preserve image content in tool messages#963

Open
cdreetz wants to merge 1 commit intomainfrom
fix/preserve-images-in-tool-messages
Open

Preserve image content in tool messages#963
cdreetz wants to merge 1 commit intomainfrom
fix/preserve-images-in-tool-messages

Conversation

@cdreetz
Copy link
Collaborator

@cdreetz cdreetz commented Feb 27, 2026

`content_to_text()` in `OpenAIChatCompletionsClient.to_native_prompt` was stripping `image_url` parts from `ToolMessage` content before sending to the API. This meant VLM models never saw screenshots returned by browser tools (CUA mode).

Uses `normalize_content()` instead, consistent with how system, user, and assistant messages already handle multipart content.


Note

Low Risk
Low risk: a small change to prompt serialization so ToolMessage content is no longer flattened to text, but it could alter what gets sent to the OpenAI API for tool responses.

Overview
Ensures ToolMessage content passed to the Chat Completions API preserves multipart payloads (e.g., image_url parts) by switching from content_to_text() to normalize_content() in OpenAIChatCompletionsClient.to_native_prompt.

This aligns tool-message serialization with system/user/assistant handling so non-text tool outputs are no longer dropped before reaching vision-capable models.

Written by Cursor Bugbot for commit 2404c42. This will update automatically on new commits. Configure here.

content_to_text() was stripping image_url parts from ToolMessage
content before sending to the API. This meant VLM models never saw
screenshots returned by browser tools (CUA mode). Use
normalize_content() instead, consistent with how all other message
types handle multipart content.
@cdreetz
Copy link
Collaborator Author

cdreetz commented Feb 27, 2026

@willccbb

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.

1 participant