Skip to content

fix(agent-runtime): restore MCP resource text in toolResultFromUi - #1878

Merged
vastsa merged 2 commits into
vastsa:mainfrom
xpeng5278-web:fix/toolresult-mcp-resource-restore
Oct 25, 2026
Merged

vastsa merged 2 commits into
vastsa:mainfrom
xpeng5278-web:fix/toolresult-mcp-resource-restore

Conversation

@xpeng5278-web

Copy link
Copy Markdown
Contributor

fix(agent-runtime): restore MCP resource text in toolResultFromUi

Fixes #1877

What

toolResultFromUi now runs persisted content blocks through the same hostContentBlockText rule as live execution, for both the MCP content property shape and the plugin bare content-block array. Embedded text resources and resource_link blocks are pushed as { type: "text", text }; images stay as before; binary resources with no text are still ignored.

Why

#1551 fixed the live path so MCP resource text reaches the model, but session restore still dropped those blocks. A resource-only row restored as "[no tool result recorded]", and a status + resource + resource_link row kept only the status (and image).

How tested

  • New cases in runtime.test.ts fail on unmodified main (resource-only → placeholder; mixed row loses body/link) and pass with this change.
  • packages/agent-runtime: vitest run src/runtime.test.ts -t "toolResultFromUi" → 15/15 pass (325 skipped); tsc -p tsconfig.json --noEmit clean.

Scope

runtime.ts (toolResultFromUi only) and its tests. Live execute path unchanged. Note: delegation-history.ts has a private copy of the same helper that still only restores text/image; left out of this PR’s scope.

xpeng5278-web and others added 2 commits October 25, 2026 17:40
Session restore copied only text and image blocks out of a persisted tool
row. An MCP result that was only an embedded text resource came back as
"[no tool result recorded]", and a status line plus a resource plus a
resource_link kept the status and dropped the file body and the link.
Live execution already keeps those through hostContentBlockText; restore
now uses that same rule for both content shapes.
@vastsa
vastsa merged commit 9944b39 into vastsa:main Oct 25, 2026
5 of 6 checks passed

This branch was previously deployed

1 inactive deployment
Preview — 0fa687db Deployed Oct 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Session restore drops MCP resource / resource_link from tool results

2 participants