feat(planners): standardized structured content blocks for planner output#6185
Open
vaibhav-patel wants to merge 2 commits into
Open
feat(planners): standardized structured content blocks for planner output#6185vaibhav-patel wants to merge 2 commits into
vaibhav-patel wants to merge 2 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.
Fixes google#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. |
Author
|
@googlebot I signed it! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.