Repository navigation
agent-host: fix image detection in browser screenshot tool - #316753
Merged
Merged
Conversation
Fixes the type field for embedded resources in tool results so that images are properly recognized by the SDK. The tool was returning images with a content type in the 'type' field instead of the semantic 'image' marker. This ensures that when the Integrated Browser screenshot tool returns image content, the Agent Host correctly identifies and surfaces those images in the chat UI. Fixes #315947 (Commit message generated by Copilot)
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes how embedded binary tool results are translated into Copilot SDK binaryResultsForLlm, ensuring image resources are tagged with the semantic type: 'image' marker (instead of a MIME string) so the SDK/LLM can recognize screenshots as images.
Changes:
- Update embedded resource mapping to emit
type: 'image'forimage/*MIME types andtype: 'resource'otherwise. - Keep MIME type in
mimeTypewhile correcting the semantictypediscriminator.
Show a summary per file
| File | Description |
|---|---|
| src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts | Fixes binary embedded-resource type tagging so screenshots are recognized as images by the Copilot SDK. |
Copilot's findings
Comments suppressed due to low confidence (1)
src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts:626
- Add a regression assertion for
binaryResultsForLlmhere (and specifically that anEmbeddedResourcewithcontentType: 'image/png'results intype: 'image'). Without a test, it’s easy to reintroduce the previous behavior where the SDK can’t recognize images in tool results.
const binaryResults = result.content
?.filter(c => c.type === ToolResultContentType.EmbeddedResource)
.map(c => ({ data: c.data, mimeType: c.contentType, type: /^image(\/|$)/.test(c.contentType) ? 'image' : 'resource' }));
if (result.success) {
deferred.complete({
textResultForLlm: textContent,
resultType: 'success',
binaryResultsForLlm: binaryResults?.length ? binaryResults : undefined,
- Files reviewed: 1/1 changed files
- Comments generated: 1
Vijay Upadya (vijayupadya)
approved these changes
May 16, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 the type field for embedded resources in tool results so that images
are properly recognized by the SDK. The tool was returning images with a
content type in the 'type' field instead of the semantic 'image' marker.
This ensures that when the Integrated Browser screenshot tool returns
image content, the Agent Host correctly identifies and surfaces those images
in the chat UI.
Fixes #315947
(Commit message generated by Copilot)