Repository navigation
fix(agent-runtime): keep MCP embedded resource text in tool results - #1551
Conversation
A host tool result shaped as MCP content only forwarded text and image blocks to the model. github-mcp-server get_file_contents returns a status line plus the file body as an embedded text resource (and a resource link for large files), so the model saw "successfully downloaded text file" and never the file. Render embedded text resources and resource links into the model-visible text alongside sibling text blocks.
muzimu217
left a comment
There was a problem hiding this comment.
Verified locally on macOS (worktree off current main): agent-runtime full suite 96 files / 1329 tests pass, including the new embedded-resource cases.
The fix restores a real capability loss: github-mcp-server's get_file_contents returns the file body as an embedded resource block, and the host bridge was passing through only text and image blocks — so the agent saw "successfully downloaded text file" with no file. hostContentBlockText handling resource/resource_link (with the resource URI in the rendered text, so the model can cite what it read) applied on both the content branch and the bare content-block-array branch is the right minimal shape.
One nuance worth stating in the review for future readers (not blocking): a large embedded resource now lands in full in the model context, which can push long files toward the overflow path — acceptable, since #1517's classification (merged) makes that surface correctly instead of looping.
Nothing blocking. fix scope, fits the window.
vastsa
left a comment
There was a problem hiding this comment.
Confirmed that host tool normalization kept only text and image blocks, which dropped embedded text resources and resource links whenever a status line was present. The fix handles both MCP content shapes and preserves the body/link for the model. Current-main checks all pass.
Summary
Fixes #1549
When an MCP tool result has a text block, the host tool bridge sent only text and image blocks to the model. It dropped
resource(embedded resource) andresource_linkblocks. github-mcp-serverget_file_contentsreturns a status line plus the file body as an embedded text resource, so the agent saw "successfully downloaded text file" but not the file.This change adds a small
hostContentBlockTexthelper, used by both the MCPcontentbranch and the bare content-block-array branch:text→ its text (unchanged)resourcewithresource.text→ the resource textresource_link→ a one-line[resource link] <name>: <uri>referenceImage handling,
details, and the JSON fallback for results with no text-like blocks are unchanged. Restored history already reads the normalizedcontent, so the text survives a restart.Tests
runtime.test.tscase uses the github-mcp-server response shape (status text + embedded resource + resource link). It fails on main (the model text is only the status line) and passes with this change.packages/agent-runtime:vitest run→ 96 files / 1329 tests pass;tsc --noEmitclean.pnpm lint:biome,pnpm check:pr-basepass.Docs
docs/spec/03-runtime/02-agent-runtime.md§3.3 now documents embedded text resources and resource links.