fix(skills,daemon): forward sanitized MCP image result blocks to the model - #511
Merged
Merged
Conversation
The bridge keeps only text content from an MCP tool result, so a server that returns a screenshot leaves the agent with "Tool returned no text content" and no image. Pin the expected behavior: sanitized image parts after the text, a runtime-authored untrusted-output notice, content-free drop reporting, and a visible notice instead of a silent drop when no image policy is configured.
…model Route `image` content blocks from MCP tool results through the same sharp-backed sanitizer browser screenshots use, consider at most four blocks per call (bounding sanitizer work, not just kept output), keep text first, and prefix a runtime-authored notice that the frames are untrusted tool output. Every dropped block — sanitizer rejection, limit, unreadable data, or no policy — is reported content-free and named in the result so the agent never mistakes a dropped frame for an empty result. The daemon wires the policy through a small helper so the composition root stays under the file-size cap and the errorKind literal resolves for the log-payload gate. Documented under "Image results" in the MCP guide.
12 tasks
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
The MCP tool bridge kept only
textcontent from a tool result, so a server that returns a screenshot (or anyimageblock) left the agent with "Tool returned no text content" and no image. This forwards MCP image result blocks to the model, sanitized and bounded.imagecontent blocks from MCP tool results through the same sharp-backed sanitizer that browser screenshots use.setup-tools-mcp-images.ts) so the composition root stays under the file-size cap and theerrorKindliteral resolves for the log-payload gate.Commits are test-first and this PR is intended for rebase-merge to keep the pair:
test(skills): expose MCP image result blocks dropped by the tool bridge— failing tests on the pre-patch bridge.fix(skills,daemon): forward sanitized MCP image result blocks to the model— the production patch.Related Issue
N/A: no tracking issue exists — the defect was found while designing the computer-use integration (MCP servers that return screenshots were silently reduced to "Tool returned no text content"). This PR is the first record of it.
Type of Change
Checklist
packages/skillsbridge tests 88/88;packages/daemonsetup-tools-mcp-images.test.ts2/2)pnpm validate— ran green as the pre-push hook on the rebased head9959e0b4)N/Areason aboveRED Test Proof
Run at the test-only commit
8a469dee(before the production patch),packages/skills:After the production patch (
9959e0b4):Test Files 2 passed (2),Tests 88 passed (88).Evidence and Residual Risk
Additional Notes
ci.ymlonly runs for PRs intomain, so the gate for this PR intorelease/1.0.64-prepis the localpnpm validatepre-push hook (green on the pushed head).🤖 Generated with Claude Code