Skip to content

fix(agent_tool): ensure text output when skip_summarization is True#4390

Open
ItsMacto wants to merge 5 commits intogoogle:mainfrom
ItsMacto:fix/agent-tool-skip-summarization-v2
Open

fix(agent_tool): ensure text output when skip_summarization is True#4390
ItsMacto wants to merge 5 commits intogoogle:mainfrom
ItsMacto:fix/agent-tool-skip-summarization-v2

Conversation

@ItsMacto
Copy link

@ItsMacto ItsMacto commented Feb 6, 2026

When skip_summarization=True, AgentTool previously terminated the flow with a FunctionResponse event that contained no text, leaving UIs stuck.

This change appends a Text part to the response event when summarization is skipped, so the tool's output is displayed. The implementation avoids duplication, safely serializes non-string results, and preserves existing behavior for normal flows.

Added regression tests to verify text output is present for both string and JSON-like tool results.

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

Problem:
When skip_summarization=True, the final response event emitted by AgentTool contains only a FunctionResponse and no displayable text. Most UIs do not render function responses, making the agent appear to hang or return an empty result.

Solution:
When skip summarization is enabled, the function result is additionally included as a Text part in the response event. If the result is a string, it is used directly; otherwise, it is safely serialized to JSON for display. This ensures the final event remains displayable while preserving existing behavior for non-skip paths.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Passed tests:

  • pytest tests/unittests/tools/test_agent_tool.py

Manual End-to-End (E2E) Tests:

Not required. The change affects event construction and is fully covered by unit tests validating the final response content.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

When skip_summarization=True, AgentTool previously terminated the flow
with a FunctionResponse event that contained no text, causing UIs to
appear stuck.

This change appends a Text part to the response event when skipping
summarization so tool output is displayed. The implementation avoids
duplication, safely serializes non-string results, and preserves
existing behavior for normal flows.

Added regression tests to verify text output is present for both string
and JSON-like tool results.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ItsMacto, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical user experience issue where the AgentTool would not provide any visible output to the user interface when the skip_summarization flag was enabled. The change ensures that the raw output of the tool, whether a simple string or a complex JSON structure, is always included as a displayable text part in the final response event. This prevents UIs from appearing to hang and provides immediate feedback to the user, significantly improving the interaction flow.

Highlights

  • Fix for UI hang with skip_summarization: When skip_summarization=True in AgentTool, the system previously terminated the flow with a FunctionResponse event that lacked displayable text, causing UIs to appear stuck. This PR resolves that by ensuring a text output is always present.
  • Ensuring displayable text output: A Text part is now appended to the response event when summarization is skipped. If the tool's result is a string, it's used directly; otherwise, non-string results are safely serialized to JSON for display.
  • Regression tests added: New regression tests have been introduced to verify that text output is correctly present for both string and JSON-like tool results when summarization is skipped, ensuring the fix is robust.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/google/adk/flows/llm_flows/functions.py
    • Imported the json module to handle serialization of non-string results.
    • Added conditional logic within __build_response_event to append a Text part to the event's content if tool_context.actions.skip_summarization is true. This text part contains the tool's result, serialized to JSON if not already a string.
  • tests/unittests/tools/test_agent_tool.py
    • Added test_agent_tool_skip_summarization_has_text_output to verify that a final event contains text content when skip_summarization is enabled and the tool returns a string.
    • Added test_agent_tool_skip_summarization_preserves_json_string_output to confirm that structured JSON output is correctly preserved and included as text when skip_summarization is enabled.
Activity
  • No human activity (comments, reviews) has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@ItsMacto
Copy link
Author

ItsMacto commented Feb 6, 2026

/gemini review

@adk-bot adk-bot added the core [Component] This issue is related to the core interface and implementation label Feb 6, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses an issue where UIs could get stuck when skip_summarization=True by ensuring a text part is always included in the final event. The implementation correctly adds a text representation of the tool's output, and includes new regression tests.

My review includes a suggestion to refine the serialization logic for non-string results to provide a cleaner output. Additionally, I've recommended strengthening the new test assertions and expanding test coverage to better validate the fix.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses an issue where AgentTool would not produce a displayable text output when skip_summarization is enabled, causing UIs to appear stuck. The fix correctly appends a Text part to the response event, serializing non-string results to ensure there's always a visible output. The added regression tests effectively cover the new functionality. My review includes suggestions to strengthen the assertions in these new tests to make them more precise and less prone to false positives.

…the 'result' key for JSON display.

- assert the exact string content
- new test case for a non-string dictionary
- more precise assertion checking for the exact text content
@ItsMacto
Copy link
Author

ItsMacto commented Feb 6, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes an issue where the UI would hang when skip_summarization=True by ensuring a text part is always included in the final event. The implementation correctly handles both string and non-string results from the tool. The accompanying tests are thorough and cover the key scenarios. My review includes a suggestion to refactor the implementation for better readability and another to reduce code duplication in the new tests using a pytest fixture.

ItsMacto and others added 2 commits February 6, 2026 04:28
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@ItsMacto
Copy link
Author

ItsMacto commented Feb 6, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively addresses the issue of UIs hanging when skip_summarization=True by ensuring a text part is always included in the function response event. The implementation correctly handles both string and non-string (JSON-serializable) tool outputs. The new unit tests are comprehensive and validate the fix across different scenarios. The changes are well-implemented and solve the problem described. I have one minor suggestion to improve code clarity and maintainability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core [Component] This issue is related to the core interface and implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The agent doesn't work as expected when "skip_summarization" is set to True in AgentTool

2 participants