From 555a66f23b2dc623dfc6654383ab7ab46bc8667e Mon Sep 17 00:00:00 2001 From: AlexeyChernenkoPlato Date: Fri, 15 Aug 2025 19:16:16 +0300 Subject: [PATCH] fix: double function response processing issue --- .../adk/flows/llm_flows/base_llm_flow.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/google/adk/flows/llm_flows/base_llm_flow.py b/src/google/adk/flows/llm_flows/base_llm_flow.py index 35c2a69c14..de2dab0c54 100644 --- a/src/google/adk/flows/llm_flows/base_llm_flow.py +++ b/src/google/adk/flows/llm_flows/base_llm_flow.py @@ -173,6 +173,15 @@ async def run_live( # cancel the tasks that belongs to the closed connection. send_task.cancel() await llm_connection.close() + # transfer to the sub agent. + transfer_to_agent = event.actions.transfer_to_agent + if transfer_to_agent: + agent_to_run = self._get_agent_to_run( + invocation_context, transfer_to_agent + ) + async with Aclosing(agent_to_run.run_live(invocation_context)) as agen: + async for item in agen: + yield item if ( event.content and event.content.parts @@ -547,15 +556,6 @@ async def _postprocess_live( ) yield final_event - transfer_to_agent = function_response_event.actions.transfer_to_agent - if transfer_to_agent: - agent_to_run = self._get_agent_to_run( - invocation_context, transfer_to_agent - ) - async with Aclosing(agent_to_run.run_live(invocation_context)) as agen: - async for item in agen: - yield item - async def _postprocess_run_processors_async( self, invocation_context: InvocationContext, llm_response: LlmResponse ) -> AsyncGenerator[Event, None]: