Skip to content

fix(adk): only compact MCP App results that carry a render payload - #2793

Closed
wangzhengzhuo05 wants to merge 1 commit into
kagent-dev:mainfrom
wangzhengzhuo05:fix/mcp-app-compact-render-only
Closed

wangzhengzhuo05 wants to merge 1 commit into
kagent-dev:mainfrom
wangzhengzhuo05:fix/mcp-app-compact-render-only

Conversation

@wangzhengzhuo05

Copy link
Copy Markdown

Summary

MakeMCPAppModelResultCallback replaced the result of every MCP App-capable tool with the canned render notice, even when an individual call returned an ordinary text-only result (no structuredContent, no _meta.ui). That hid real content from the model.

The callback now collapses a successful result only when the result itself carries a render payload — a non-nil structuredContent or a _meta.ui.resourceUri — and passes plain results through unchanged. This mirrors the Python-side fix in #2579 so Go and Python stop drifting on MCP App semantics.

What changed

  • go/adk/pkg/mcp/mcp_ui.go: add an exported HasUIResource(meta) helper that reuses the existing parseMCPUIMetadata as the single source of truth for _meta.ui parsing.
  • go/adk/pkg/agent/mcp_apps.go: gate the success-path compaction on result.StructuredContent == nil && !kagentmcp.HasUIResource(result.Meta); return the response unchanged when there is no render payload. The isError path keeps its existing behaviour.
  • go/adk/pkg/agent/mcp_apps_test.go: add a regression test using the issue's repro — an app-declared tool returning only content: [{type: text, text: "No build found for job demo/1: it was deleted."}] must reach the model unchanged.

Why not just branch on IsError

A tool declaring _meta.ui.resourceUri is capable of rendering an app; a given call may still return plain content (e.g. "not found"). Deciding from the tool name alone conflates capability with an actual render payload, which is what the regression covers.

Verification

  • go test ./adk/pkg/agent/... -count=1 — pass (4 MCP App tests: 3 pre-existing + 1 new)
  • go test ./adk/pkg/mcp/... -count=1 — pass
  • go build ./... — pass
  • Mutation check: with the new guard disabled, TestMakeMCPAppModelResultCallbackPassesThroughPlainResultFromAppTool fails exactly as expected (the plain text is replaced by the render notice). Restored afterwards.

Fixes #2716

Signed-off-by: wangzhengzhuo05 <175673456+wangzhengzhuo05@users.noreply.github.com>
@github-actions github-actions Bot added the bug Something isn't working label Sep 10, 2026
@wangzhengzhuo05

Copy link
Copy Markdown
Author

Closing this to keep the tracker clean \u2014 it has been sitting without review for several days. This is no reflection on the change itself: the fix and its local verification still stand. If the issue is still present and you would like the patch revisited, say the word and I will rebase it onto current main and re-open. Thanks for your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

go/adk: MakeMCPAppModelResultCallback blanks non-UI tool results, same gap #2579 fixed in Python

1 participant