From d0f49487058e5da462f650467c7baa6f7ef14ea5 Mon Sep 17 00:00:00 2001 From: Fedor V <738925+sumkincpp@users.noreply.github.com> Date: Wed, 26 Nov 2025 19:33:03 +0100 Subject: [PATCH 1/2] fix(agent_tool): handle case when last_content.parts are unavailable --- src/google/adk/tools/agent_tool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/google/adk/tools/agent_tool.py b/src/google/adk/tools/agent_tool.py index 46d8616619..f700cdd822 100644 --- a/src/google/adk/tools/agent_tool.py +++ b/src/google/adk/tools/agent_tool.py @@ -186,7 +186,7 @@ async def run_async( # to avoid "Attempted to exit cancel scope in a different task" errors await runner.close() - if not last_content: + if not last_content or not last_content.parts: return '' merged_text = '\n'.join(p.text for p in last_content.parts if p.text) if isinstance(self.agent, LlmAgent) and self.agent.output_schema: From 87fca92bcafa42608d4e0087781c39a15db2b641 Mon Sep 17 00:00:00 2001 From: Fedor V <738925+sumkincpp@users.noreply.github.com> Date: Wed, 26 Nov 2025 19:54:27 +0100 Subject: [PATCH 2/2] fix(agent_tool): case when merged_text is empty --- src/google/adk/tools/agent_tool.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/google/adk/tools/agent_tool.py b/src/google/adk/tools/agent_tool.py index f700cdd822..e08b71d159 100644 --- a/src/google/adk/tools/agent_tool.py +++ b/src/google/adk/tools/agent_tool.py @@ -189,6 +189,9 @@ async def run_async( if not last_content or not last_content.parts: return '' merged_text = '\n'.join(p.text for p in last_content.parts if p.text) + # no text present -> no json, return empty string + if not merged_text: + return '' if isinstance(self.agent, LlmAgent) and self.agent.output_schema: tool_result = self.agent.output_schema.model_validate_json( merged_text