Uh oh!
There was an error while loading. Please reload this page.
feat(planners): standardized structured content blocks for planner output - #6185
feat(planners): standardized structured content blocks for planner output#6185vaibhav-patel wants to merge 5 commits into
Conversation
PlanReActPlanner and BuiltInPlanner emit their output as a list of
google.genai Part objects where reasoning is signalled only by
``thought=True`` and, for PlanReActPlanner, by inline ``/*PLANNING*/``
style tags embedded in the text. Consumers that want a structured view
of the plan/reasoning/answer have to re-parse that raw text themselves.
Add a small, additive, read-only converter that turns planner-produced
parts into a provider-agnostic list of typed content blocks modelled
after LangChain v1's standard content blocks:
[{'type': 'reasoning', 'reasoning': ..., 'reasoning_kind': ...},
{'type': 'tool_call', 'name': ..., 'args': ..., 'id': ...},
{'type': 'text', 'text': ...}]
The new ``planner_content_blocks`` module exposes ``parts_to_content_blocks``
/ ``part_to_content_block`` plus the block TypedDicts, and both planners
gain a ``to_content_blocks`` convenience method. The conversion never
mutates the parts and does not change ``build_planning_instruction`` or
``process_planning_response``, so existing Part-based consumers and the
NL planning flow are unaffected.
Fixesgoogle#3378.Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
vaibhav-patel
commented
Jun 22, 2026
@googlebot I signed it! |
rohityan
commented
Jun 26, 2026
Hi @vaibhav-patel, Thank you for your contribution! We appreciate you taking the time to submit this pull request. |
Summary
Fixes#3378.
PlanReActPlannerandBuiltInPlanneremit their output asgoogle.genaiPartlists where reasoning is signalled only bythought=Trueand, forPlanReActPlanner, by inline/*PLANNING*/-style tags embedded in the text. Consumers that want a structured view of plan/reasoning/answer must re-parse that raw text.This PR adds a small, additive, read-only converter that turns planner output into a provider-agnostic list of typed content blocks modelled after LangChain v1's standard content blocks:
[{'type': 'reasoning', 'reasoning': '...', 'reasoning_kind': 'planning'}, {'type': 'tool_call', 'name': '...', 'args': {...}, 'id': None}, {'type': 'text', 'text': '...'}]What's added
google.adk.planners.planner_content_blocksmodule:parts_to_content_blocks/part_to_content_blockand theReasoningContentBlock/TextContentBlock/ToolCallContentBlockTypedDicts.to_content_blocks(...)convenience method on both planners.PlanReActPlanner, the inline tag is mapped to a fine-grainedreasoning_kind(planning/replanning/reasoning/action) and stripped from the standardized text; forBuiltInPlanner, native thinking parts becomereasoningblocks withreasoning_kind=None.What's not changed
build_planning_instruction,process_planning_response, and the NL planning flow are untouched. The conversion never mutates its input, so existingPart-based consumers are unaffected.Tests
New
tests/unittests/planners/test_planner_content_blocks.py(21 tests): per-part mapping, tag→kind mapping, skip rules (empty parts, redacted thoughts, empty function-call names), order preservation, no-mutation guarantees, and end-to-endprocess_planning_response→to_content_blocksround-trips for both planners. Fulltests/unittests/planners/(23) andtests/unittests/flows/llm_flows/(381) pass.Fixes#3378.