From a4f2323cdbee8d13e621664891be6ebaf46dfaf0 Mon Sep 17 00:00:00 2001 From: Amaad Martin Date: Wed, 12 Aug 2026 21:09:42 -0700 Subject: [PATCH] refactor(flows): drop the dead 'if False:' async-generator sentinel The three request processors _NlPlanningRequestProcessor, _ContentLlmRequestProcessor and _IdentityLlmRequestProcessor guarded their trailing yield with 'if False:'. Every other processor in the package uses an explicit 'return' before the yield instead. Converge on that form. Behaviour is identical: a function is an async generator because the compiler sees a yield lexically in the body, not because the yield can run. All three processors still yield zero events. --- src/google/adk/flows/llm_flows/_nl_planning.py | 5 ++--- src/google/adk/flows/llm_flows/contents.py | 5 ++--- src/google/adk/flows/llm_flows/identity.py | 5 ++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/google/adk/flows/llm_flows/_nl_planning.py b/src/google/adk/flows/llm_flows/_nl_planning.py index 518483dbc8e..ccb27c90c31 100644 --- a/src/google/adk/flows/llm_flows/_nl_planning.py +++ b/src/google/adk/flows/llm_flows/_nl_planning.py @@ -60,9 +60,8 @@ async def run_async( _remove_thought_from_request(llm_request) - # Maintain async generator behavior - if False: # Ensures it behaves as a generator - yield # This is a no-op but maintains generator structure + return + yield # AsyncGenerator requires a yield in function body. request_processor = _NlPlanningRequestProcessor() diff --git a/src/google/adk/flows/llm_flows/contents.py b/src/google/adk/flows/llm_flows/contents.py index f51211d7940..36f42a606fd 100644 --- a/src/google/adk/flows/llm_flows/contents.py +++ b/src/google/adk/flows/llm_flows/contents.py @@ -132,9 +132,8 @@ async def run_async( invocation_context, llm_request, instruction_related_contents ) - # Maintain async generator behavior - if False: # Ensures it behaves as a generator - yield # This is a no-op but maintains generator structure + return + yield # AsyncGenerator requires a yield in function body. request_processor = _ContentLlmRequestProcessor() diff --git a/src/google/adk/flows/llm_flows/identity.py b/src/google/adk/flows/llm_flows/identity.py index c168e73bf13..6abb8ec8708 100644 --- a/src/google/adk/flows/llm_flows/identity.py +++ b/src/google/adk/flows/llm_flows/identity.py @@ -41,9 +41,8 @@ async def run_async( si += f' The description about you is "{agent.description}".' llm_request.append_instructions([si]) - # Maintain async generator behavior - if False: # Ensures it behaves as a generator - yield # This is a no-op but maintains generator structure + return + yield # AsyncGenerator requires a yield in function body. request_processor = _IdentityLlmRequestProcessor()