From 08a4fa7e9e1337ec77e48ddd1b6b872fc00660ec Mon Sep 17 00:00:00 2001 From: hanmingalbertyang Date: Mon, 27 Oct 2025 11:49:08 -0400 Subject: [PATCH] Skip events without content when finding the last transfer agent. Events without content, such as those from callbacks with state_deltas, do not represent a transfer to an agent that should continue the conversation. --- src/google/adk/agents/llm_agent.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/google/adk/agents/llm_agent.py b/src/google/adk/agents/llm_agent.py index c143568252..5f4c94a6d1 100644 --- a/src/google/adk/agents/llm_agent.py +++ b/src/google/adk/agents/llm_agent.py @@ -631,7 +631,10 @@ def _get_subagent_to_resume( # Last event is from another agent, or from user for another agent's tool # call. We need to find the last agent we transferred to. - for event in reversed(events): + # Events without content, potentially from callbacks with state_deltas, + # should be skipped as they don't represent a transfer to an agent + # that should continue the conversation with the user. + for event in (e for e in reversed(events) if e.content): if agent := self.__get_transfer_to_agent_or_none(event, self.name): return agent