diff --git a/src/google/adk/tools/agent_tool.py b/src/google/adk/tools/agent_tool.py index 46d8616619..e08b71d159 100644 --- a/src/google/adk/tools/agent_tool.py +++ b/src/google/adk/tools/agent_tool.py @@ -186,9 +186,12 @@ 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) + # 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