Skip to content

agent-host: fix image detection in browser screenshot tool - #316753

Merged
Connor Peet (connor4312) merged 1 commit into
mainfrom
connor4312/315947
May 16, 2026
Merged

Connor Peet (connor4312) merged 1 commit into
mainfrom
connor4312/315947

Conversation

@connor4312

Copy link
Copy Markdown
Member

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)

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)
Copilot AI review requested due to automatic review settings May 16, 2026 05:37
@connor4312
Connor Peet (connor4312) enabled auto-merge (squash) May 16, 2026 05:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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' for image/* MIME types and type: 'resource' otherwise.
  • Keep MIME type in mimeType while correcting the semantic type discriminator.
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 binaryResultsForLlm here (and specifically that an EmbeddedResource with contentType: 'image/png' results in type: '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

@connor4312
Connor Peet (connor4312) merged commit 1221f4b into main May 16, 2026
29 checks passed
@connor4312
Connor Peet (connor4312) deleted the connor4312/315947 branch May 16, 2026 06:58
@vs-code-engineering vs-code-engineering Bot added this to the 1.121.0 milestone May 16, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Jun 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent Host: Agent can't see images returned by Integrated Browser screenshots tool

3 participants