Skip to content

fix(flows): scope skip_summarization text-append to AgentTool#6231

Open
lwangverizon wants to merge 1 commit into
google:mainfrom
lwangverizon:fix/skip-summarization-agenttool-scope
Open

fix(flows): scope skip_summarization text-append to AgentTool#6231
lwangverizon wants to merge 1 commit into
google:mainfrom
lwangverizon:fix/skip-summarization-agenttool-scope

Conversation

@lwangverizon

Copy link
Copy Markdown
Contributor

fix(flows): scope skip_summarization text-append to AgentTool

Fixes #6230

Problem

PR #5974 (issue #3881) added a text part to the function-response event when
skip_summarization is True, so an AgentTool's output stays visible in UIs
that do not render function responses. The condition in __build_response_event
(src/google/adk/flows/llm_flows/functions.py) is not guarded by tool type, so
it fires for every tool that sets skip_summarization:

if (
    tool_context.actions.skip_summarization
    and 'error' not in function_result
    and has_displayable_result
):
    ...
    content.parts.append(types.Part.from_text(text=result_text))

Tools other than AgentTool often set skip_summarization for the opposite
reason: their function response is an internal acknowledgement (e.g. a
UI/widget-rendering tool returning {"status": "ok"}) that should not be
summarized or shown to the user. Force-converting that ack into a text Part
makes it bypass UI/SSE filters that only strip
functionResponse/functionCall/thought parts, so the raw payload is
surfaced to the user as visible text.

Issue #3881 and PR #5974 are both explicitly about AgentTool, so this is a
scope/regression issue rather than an intended behavior change for all tools.

Change

Guard the text-append with isinstance(tool, AgentTool):

if (
    isinstance(tool, AgentTool)
    and tool_context.actions.skip_summarization
    and 'error' not in function_result
    and has_displayable_result
):
    ...

Tests

  • Adds test_skip_summarization_non_agent_tool_appends_no_text_part in
    tests/unittests/flows/llm_flows/test_functions_simple.py: a FunctionTool
    that sets skip_summarization=True and returns a dict produces only a
    function_response part and no text part.
  • The existing AgentTool skip_summarization tests
    (tests/unittests/tools/test_agent_tool.py, added by feat(skills): Allow opt-in session state injection in skill instructions #5974) continue to pass,
    confirming the intended behavior is preserved.

Backwards compatibility

Narrows an over-broad behavior introduced in #5974 back to its stated scope
(AgentTool). No public API or signature change.

PR google#5974 (issue google#3881) added a text part to the function-response event when
skip_summarization is True, so an AgentTool's output stays visible in UIs that
do not render function responses. The condition was not guarded by tool type,
so it fires for every tool that sets skip_summarization.

Tools other than AgentTool set skip_summarization for the opposite reason:
their function response is an internal acknowledgement (e.g. a UI/widget tool
returning {"status": "ok"}) that should not be summarized or shown to the
user. Force-converting that ack into a text Part makes it bypass UI/SSE
filters that only strip functionResponse/functionCall/thought parts, so the
raw payload is surfaced to the user as visible text.

Scope the append to AgentTool via isinstance, matching the original change's
stated intent (issue google#3881 is specifically about AgentTool). AgentTool keeps
its text output; other tools no longer have their function response duplicated
as text. AgentTool is imported lazily to avoid the
agents -> flows -> tools -> agents circular import.

Adds a regression test: a non-AgentTool with skip_summarization=True produces
only a function_response part and no text part. The existing AgentTool
skip_summarization tests continue to pass.
@lwangverizon lwangverizon force-pushed the fix/skip-summarization-agenttool-scope branch from 162aa59 to e845f95 Compare June 28, 2026 02:30
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.

skip_summarization text-append in __build_response_event is not scoped to AgentTool

1 participant