Repository navigation
fix(adk): only compact MCP App results that carry a render payload - #2793
Closed
wangzhengzhuo05 wants to merge 1 commit into
Closed
wangzhengzhuo05 wants to merge 1 commit into
wangzhengzhuo05 wants to merge 1 commit into
Conversation
Signed-off-by: wangzhengzhuo05 <175673456+wangzhengzhuo05@users.noreply.github.com>
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. |
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.
Summary
MakeMCPAppModelResultCallbackreplaced the result of every MCP App-capable tool with the canned render notice, even when an individual call returned an ordinary text-only result (nostructuredContent, 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
structuredContentor 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 exportedHasUIResource(meta)helper that reuses the existingparseMCPUIMetadataas the single source of truth for_meta.uiparsing.go/adk/pkg/agent/mcp_apps.go: gate the success-path compaction onresult.StructuredContent == nil && !kagentmcp.HasUIResource(result.Meta); return the response unchanged when there is no render payload. TheisErrorpath 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 onlycontent: [{type: text, text: "No build found for job demo/1: it was deleted."}]must reach the model unchanged.Why not just branch on
IsErrorA tool declaring
_meta.ui.resourceUriis 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— passgo build ./...— passTestMakeMCPAppModelResultCallbackPassesThroughPlainResultFromAppToolfails exactly as expected (the plain text is replaced by the render notice). Restored afterwards.Fixes #2716