Skip to content

Add to_content_blocks() to BasePlanner for standardized content block output - #6612

Open
guptaishaan wants to merge 1 commit into
google:mainfrom
guptaishaan:fix/issue-3378-7806
Open

Add to_content_blocks() to BasePlanner for standardized content block output#6612
guptaishaan wants to merge 1 commit into
google:mainfrom
guptaishaan:fix/issue-3378-7806

Conversation

@guptaishaan

Copy link
Copy Markdown
Contributor

Both PlanReActPlanner and BuiltInPlanner expose their output as a raw list of google.genai.types.Part objects, making it hard for callers to consume planning results in a provider-neutral way.

This PR adds a concrete to_content_blocks() method to BasePlanner that converts List[types.Part] into the standardized content block format popularised by LangChain 1.0: thought/reasoning parts become {'type': 'reasoning', 'reasoning': '...'} dicts and regular text parts become {'type': 'text', 'text': '...'} dicts; parts that carry neither (e.g. function-call parts) are skipped.

Both PlanReActPlanner and BuiltInPlanner inherit the method automatically; custom subclasses can override it if they need different mapping logic.

Four regression tests covering text+reasoning, empty input, non-text parts, and the BuiltInPlanner path are added to tests/unittests/planners/test_plan_re_act_planner.py.

Fixes #3378

… output

Both `PlanReActPlanner` and `BuiltInPlanner` expose their output as a raw list of `google.genai.types.Part` objects, making it hard for callers to consume planning results in a provider-neutral way.

Signed-off-by: Ishaan <ishaangupta0408@gmail.com>
@adk-bot adk-bot added the core [Component] This issue is related to the core interface and implementation label Aug 6, 2026
@DeanChensj

Copy link
Copy Markdown
Collaborator

Hi @guptaishaan , I think the new helper method fits better in https://github.com/google/adk-python/blob/main/src/google/adk/utils/content_utils.py, wdyt?

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

Labels

core [Component] This issue is related to the core interface and implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Standarlize content block for PlanReActPlanner and BuiltInPlanner

3 participants