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