fix(flows): scope skip_summarization text-append to AgentTool#6231
Open
lwangverizon wants to merge 1 commit into
Open
fix(flows): scope skip_summarization text-append to AgentTool#6231lwangverizon wants to merge 1 commit into
lwangverizon wants to merge 1 commit into
Conversation
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.
162aa59 to
e845f95
Compare
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.
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_summarizationis True, so anAgentTool's output stays visible in UIsthat 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, soit fires for every tool that sets
skip_summarization:Tools other than
AgentTooloften setskip_summarizationfor the oppositereason: their function response is an internal acknowledgement (e.g. a
UI/widget-rendering tool returning
{"status": "ok"}) that should not besummarized or shown to the user. Force-converting that ack into a text
Partmakes it bypass UI/SSE filters that only strip
functionResponse/functionCall/thoughtparts, so the raw payload issurfaced to the user as visible text.
Issue #3881 and PR #5974 are both explicitly about
AgentTool, so this is ascope/regression issue rather than an intended behavior change for all tools.
Change
Guard the text-append with
isinstance(tool, AgentTool):AgentToolkeeps its text output (the The agent doesn't work as expected when "skip_summarization" is set to True in AgentTool #3881 behavior is preserved).response duplicated as a visible text part.
AgentToolis imported lazily inside the function to avoid theagents -> flows -> tools -> agentscircular import (the codebase alreadylazy-imports
AgentToolelsewhere for the same reason).Tests
test_skip_summarization_non_agent_tool_appends_no_text_partintests/unittests/flows/llm_flows/test_functions_simple.py: aFunctionToolthat sets
skip_summarization=Trueand returns a dict produces only afunction_responsepart and no text part.(
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.