fix(kagent-adk): compact MCP App tool results only when the result carries a UI resource - #2579
Open
AmirF194 wants to merge 1 commit into
Open
fix(kagent-adk): compact MCP App tool results only when the result carries a UI resource#2579AmirF194 wants to merge 1 commit into
AmirF194 wants to merge 1 commit into
Conversation
…rries a UI resource compact_mcp_app_response collapsed every result from a UI-capable tool into a terminal notice, classifying purely from the tool's definition (_meta.ui.resourceUri at ListTools time) rather than the specific call result. A tool that sometimes returns plain data and sometimes renders UI (e.g. an Atlassian search tool with a UI mode) had every result blanked for headless agents (A2A, kagent invoke), even ones with no UI resource at all. Add _result_has_ui_resource, mirroring the existing _meta.ui.resourceUri / _meta["ui/resourceUri"] parsing kagent already uses to classify a tool definition (go/adk/pkg/mcp/mcp_ui.go), applied to the result instead. compact_mcp_app_response now passes a result through unchanged unless it itself declares a UI resource. Scoped to the Python ADK runtime per the issue; go/adk/pkg/agent/mcp_apps.go has the identical gap and is left as a follow-up. Fixes kagent-dev#2519 Signed-off-by: Amir Fathi <amirfathi.me@gmail.com>
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.
Root cause
compact_mcp_app_response(python/packages/kagent-adk/src/kagent/adk/_mcp_apps.py)collapses a tool's result into a terminal notice whenever the tool's name is in
app_tool_names, a set populated once from the tool's_meta.ui.resourceUriatListToolstime. A single tool can carry a UI mode without every call rendering it(the issue's example: an Atlassian search tool with a UI widget), so any plain,
data-only result from such a tool was silently replaced with the notice text for a
headless caller (A2A,
kagent invoke), with no error.Fix
Added
_result_has_ui_resource, which checks the result's own_meta.ui.resourceUri/
_meta["ui/resourceUri"], the same fieldsgo/adk/pkg/mcp/mcp_ui.goalready parsesto classify a tool's definition, applied here to the per-call result instead.
compact_mcp_app_responsenow passes a result through unchanged unless it declares aUI resource itself.
Scoped to the Python ADK runtime per the issue;
go/adk/pkg/agent/mcp_apps.gohas theidentical gap and is left as a follow-up, since it is outside this change's surface.
Verification
(empty
_meta, and no_metakey at all) now passes through unmodified. Both failon
main(asserting the old collapse) and pass on this branch; confirmed independentlyin a clean container against an unmodified worktree of
mainbefore rebuilding on thebranch.
kagent-adkunit suite (uv run pytest packages/kagent-adk/tests/unittests/):402 passed on Python 3.11 and 3.13, both CI matrix extremes.
ruff checkandruff format --diffon the two changed files: clean.block rather than
_meta(no such server available to test against); the existingand new tests all key on
_meta, matching the only shape this repo's own tests andmcp_ui.gocurrently recognize.Fixes #2519