adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

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

Open slilichenko opened this issue 11 months ago • 8 comments

In the code, the skip_summarization of Agent Tool causes the parent context to emit an event with "is_final_response()" returning True. This causes base flow interruption, which means that the loop ends with the last function response. But most of the UIs, including ADK web, don't display the output of the tool response and it appears that the agent is stuck. Furthermore, if the agent is supposed to continue working on the response, perhaps by calling other tools with the output of the first AgentTool call as input - it does't happen because the response is marked as final.

The documentation is a bit confusing because a) it doesn't cover these nuances and b) if you open the code snippet the "how it works session" covers what's not in the code (it describes what the way things works with skip_summarization = False).

IMHO, it's a code bug or a design flaw, or a documentation bug. A reproducible case: if you update this simple agent to use skip_summarization - the answer is never displayed to the user via ADK web interface. The skip summarization path generates 4 events vs 5 with summarization; the last event being the function response (and the function response text is never displayed in the ADK web UI). Happy to provide detailed screenshots if needed.

slilichenko avatar Dec 09 '25 22:12 slilichenko

Also, for me, tests Eval works fine, but Agent is exposed as A2A and the response is empty. I have a very simple agent that calls only one tool. Plus tracing shows good response, but in the caller agent its empty.

BnnaFish avatar Dec 11 '25 20:12 BnnaFish

Issue Confirmed - Root Cause Analysis

I can confirm this is a bug/design flaw. Here's what's happening:

Root Cause

The issue is in src/google/adk/events/event.py:90:

def is_final_response(self) -> bool:
    if self.actions.skip_summarization or self.long_running_tool_ids:
      return True  # ← This causes premature termination

When skip_summarization=True, any event is marked as final, which causes the main loop in base_llm_flow.py:422 to break, terminating the entire agent flow.

Why This Breaks

Normal flow (skip_summarization=False):

User → Model(function_call) → Function_response → Model(summarize) → Text shown in UI ✓

Broken flow (skip_summarization=True):

User → Model(function_call) → Function_response ← Flow ends here
                                                 ↑ UI doesn't display this

The problems:

  1. Flow terminates early - The agent can't continue processing or call additional tools
  2. Nothing displayed - UIs only show model-generated text, not raw function_response events
  3. Appears stuck - No visible output to the user

Proposed Fix

Modify is_final_response() to check if there's actual displayable content:

def is_final_response(self) -> bool:
    if self.long_running_tool_ids:
      return True

    if self.actions.skip_summarization:
      # Only treat as final if there's actual text content
      has_text_content = (
          self.content and
          self.content.parts and
          any(p.text for p in self.content.parts if not p.thought)
      )
      # Don't terminate on function_response alone
      if not has_text_content and self.get_function_responses():
        return False
      return has_text_content

    return (
        not self.get_function_calls()
        and not self.get_function_responses()
        and not self.partial
        and not self.has_trailing_code_execution_result()
    )

Alternative Solutions

  1. AgentTool emits text response - When skip_summarization=True, have AgentTool automatically create a text event with the tool output
  2. Better documentation - At minimum, clearly document that skip_summarization terminates the flow and isn't UI-friendly

Impact

This affects:

  • AgentTool with skip_summarization=True
  • Any multi-step workflows using AgentTool
  • All UI implementations (ADK web, etc.)

Happy to submit a PR with the fix if this approach looks good to the maintainers.

kkrusher avatar Jan 28 '26 03:01 kkrusher

This PR fixes this

ItsMacto avatar Feb 11 '26 00:02 ItsMacto

Hello @ItsMacto , Could you please check the PR? It looks like some checks are failing.

@ryanaiagent , could you guide us, so we can get this merged?

llalitkumarrr avatar Feb 19 '26 06:02 llalitkumarrr

Hi @ItsMacto , your PR is under review.

rohityan avatar Feb 19 '26 18:02 rohityan

Hi @rohityan , is it still under review? Anything I can do to help move forward!

ItsMacto avatar Mar 10 '26 03:03 ItsMacto

Our team has been encountering some issues related to this bug. Could you please share the current status or progress when you have a moment?

Tomoki-Iino avatar Mar 11 '26 06:03 Tomoki-Iino

@Tomoki-Iino Hi sorry. just waiting of feedback to get it merged!

ItsMacto avatar Mar 25 '26 03:03 ItsMacto