Skip to content

feat(planners): standardized structured content blocks for planner output#6185

Open
vaibhav-patel wants to merge 2 commits into
google:mainfrom
vaibhav-patel:fix/3378-planner-content-blocks
Open

feat(planners): standardized structured content blocks for planner output#6185
vaibhav-patel wants to merge 2 commits into
google:mainfrom
vaibhav-patel:fix/3378-planner-content-blocks

Conversation

@vaibhav-patel

Copy link
Copy Markdown

Summary

Fixes #3378.

PlanReActPlanner and BuiltInPlanner emit their output as google.genai Part lists 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 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

  • New google.adk.planners.planner_content_blocks module: parts_to_content_blocks / part_to_content_block and the ReasoningContentBlock / TextContentBlock / ToolCallContentBlock TypedDicts.
  • to_content_blocks(...) convenience method on both planners.
  • For PlanReActPlanner, the inline tag is mapped to a fine-grained reasoning_kind (planning / replanning / reasoning / action) and stripped from the standardized text; for BuiltInPlanner, native thinking parts become reasoning blocks with reasoning_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 existing Part-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-end process_planning_responseto_content_blocks round-trips for both planners. Full tests/unittests/planners/ (23) and tests/unittests/flows/llm_flows/ (381) pass.

Fixes #3378.

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.
@google-cla

google-cla Bot commented Jun 22, 2026

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Author

@googlebot I signed it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Standarlize content block for PlanReActPlanner and BuiltInPlanner

1 participant