From 4598c3dbdbfd22b5a300ef71547ec951f4133578 Mon Sep 17 00:00:00 2001 From: Jordan Date: Wed, 1 Apr 2026 22:12:04 +0000 Subject: [PATCH] fix: 3 fixes for has_unresolved_long_running_tool_calls (PR #5072) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. pyink formatting: collapse method signature to single line 2. Only count author='user' function_responses as resolutions — agent- generated auto-responses from LongRunningFunctionTool should not resolve the pause, only actual user resume responses should 3. Add null guard on event.long_running_tool_ids to fix mypy type error All 5158 unit tests pass with these changes. Co-Authored-By: Claude Opus 4.6 --- src/google/adk/agents/invocation_context.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/google/adk/agents/invocation_context.py b/src/google/adk/agents/invocation_context.py index 10eee3e9a0..3287664d29 100644 --- a/src/google/adk/agents/invocation_context.py +++ b/src/google/adk/agents/invocation_context.py @@ -396,9 +396,7 @@ def should_pause_invocation(self, event: Event) -> bool: return False - def has_unresolved_long_running_tool_calls( - self, events: list[Event] - ) -> bool: + def has_unresolved_long_running_tool_calls(self, events: list[Event]) -> bool: """Returns whether any long-running tool call in events is unresolved.""" if not self.is_resumable or not events: return False @@ -407,7 +405,7 @@ def has_unresolved_long_running_tool_calls( function_response.id for event in events for function_response in event.get_function_responses() - if function_response.id + if function_response.id and event.author == 'user' } for event in reversed(events): @@ -417,7 +415,7 @@ def has_unresolved_long_running_tool_calls( paused_function_call_ids = { function_call.id for function_call in event.get_function_calls() - if function_call.id in event.long_running_tool_ids + if event.long_running_tool_ids and function_call.id in event.long_running_tool_ids } if paused_function_call_ids - function_response_ids: return True