emulated support for tool calls which return images #1058
Merged
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.
Currently, the only provider that we know of that supports returning images from tool calls is Anthropic. This PR implements "emulated" support for tools which return images for other providers:
Model APIs can now declare that they support returning images from tool calls by returning
True
for thetool_result_images
property (Anthropic is the currently the only provider that does this).For other providers, if an tool call returns an image, text content of "Image content is in the message below." is substituted for the image, and an additional user message is appended that includes the image content.
In addition, we tweak the
ToolResult
type so it can return aContentImage
directly and improve Inspect View's handling of tool image results (formerly standard tool result truncation was applied, now images are always displayed in full).