From 82fe14192b285d134fffee25d56b9a3253e8fb45 Mon Sep 17 00:00:00 2001 From: Ishaan Date: Mon, 3 Aug 2026 09:12:49 +0000 Subject: [PATCH] Standardize content block handling in BuiltInPlanner.process_planning_response Previously, `BuiltInPlanner.process_planning_response()` returned `None`, and `_NlPlanningResponse` worked around this with a special identity check (`type(planner).process_planning_response is BuiltInPlanner.process_planning_response`) to skip calling it entirely. This meant the `BuiltInPlanner` never participated in the standardized content-block pipeline that `PlanReActPlanner` uses. Signed-off-by: Ishaan --- .../adk/flows/llm_flows/_nl_planning.py | 8 +------- src/google/adk/planners/built_in_planner.py | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/google/adk/flows/llm_flows/_nl_planning.py b/src/google/adk/flows/llm_flows/_nl_planning.py index 765623b5b70..79563b6fbd8 100644 --- a/src/google/adk/flows/llm_flows/_nl_planning.py +++ b/src/google/adk/flows/llm_flows/_nl_planning.py @@ -72,8 +72,6 @@ class _NlPlanningResponse(BaseLlmResponseProcessor): async def run_async( self, invocation_context: InvocationContext, llm_response: LlmResponse ) -> AsyncGenerator[Event, None]: - from ...planners.built_in_planner import BuiltInPlanner - if ( not llm_response or not llm_response.content @@ -82,11 +80,7 @@ async def run_async( return planner = _get_planner(invocation_context) - if ( - not planner - or type(planner).process_planning_response - is BuiltInPlanner.process_planning_response - ): + if not planner: return # Postprocess the LLM response. diff --git a/src/google/adk/planners/built_in_planner.py b/src/google/adk/planners/built_in_planner.py index eb665263405..ff7968fc8af 100644 --- a/src/google/adk/planners/built_in_planner.py +++ b/src/google/adk/planners/built_in_planner.py @@ -83,4 +83,21 @@ def process_planning_response( callback_context: CallbackContext, response_parts: List[types.Part], ) -> Optional[List[types.Part]]: - return + """Processes the planning response by returning the model's native content blocks. + + The BuiltInPlanner relies on the model's native thinking feature, where + reasoning parts are already marked with thought=True by the model. + This method returns the response parts as-is, preserving the standardized + content blocks produced by the model. + + Args: + callback_context: The callback context of the invocation. + response_parts: The LLM response parts. + + Returns: + The response parts with the model's native content blocks preserved, + or None if there are no parts to process. + """ + if not response_parts: + return None + return list(response_parts)