Skip to content

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
kagent-dev:mainfrom
AmirF194:fix/2519-mcp-app-compact-result-only
Open

fix(kagent-adk): compact MCP App tool results only when the result carries a UI resource#2579
AmirF194 wants to merge 1 commit into
kagent-dev:mainfrom
AmirF194:fix/2519-mcp-app-compact-result-only

Conversation

@AmirF194

Copy link
Copy Markdown

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.resourceUri at
ListTools time. 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 fields go/adk/pkg/mcp/mcp_ui.go already parses
to classify a tool's definition, applied here to the per-call result instead.
compact_mcp_app_response now passes a result through unchanged unless it declares a
UI resource itself.

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, since it is outside this change's surface.

Verification

  • New tests reproduce the issue directly: a data-only result from a UI-capable tool
    (empty _meta, and no _meta key at all) now passes through unmodified. Both fail
    on main (asserting the old collapse) and pass on this branch; confirmed independently
    in a clean container against an unmodified worktree of main before rebuilding on the
    branch.
  • Full kagent-adk unit suite (uv run pytest packages/kagent-adk/tests/unittests/):
    402 passed on Python 3.11 and 3.13, both CI matrix extremes.
  • ruff check and ruff format --diff on the two changed files: clean.
  • Not verified: a real MCP server whose result carries a UI resource via a content
    block rather than _meta (no such server available to test against); the existing
    and new tests all key on _meta, matching the only shape this repo's own tests and
    mcp_ui.go currently recognize.

Fixes #2519

…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>
@AmirF194
AmirF194 requested a review from a team as a code owner August 26, 2026 16:11
@github-actions github-actions Bot added the bug Something isn't working label Aug 26, 2026
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.

[BUG] MCP Apps compaction blanks tool results for headless agents, even when the result contains no UI resource

1 participant