Skip to content

feat(planners): add standardized planner content blocks#163

Open
vaibhav-patel wants to merge 1 commit into
google:mainfrom
vaibhav-patel:feat/planner-content-blocks
Open

feat(planners): add standardized planner content blocks#163
vaibhav-patel wants to merge 1 commit into
google:mainfrom
vaibhav-patel:feat/planner-content-blocks

Conversation

@vaibhav-patel

Copy link
Copy Markdown

What

Adds google.adk_community.planners — a read-only, additive helper that converts planner-produced google.genai.types.Part lists into LangChain v1-style typed content blocks.

  • parts_to_content_blocks(parts) / part_to_content_block(part) return typed blocks with a type discriminator:
    • reasoning — from thought=True parts; carries reasoning text and a reasoning_kind (planning / replanning / reasoning / action, derived from PlanReActPlanner inline tags, or None for BuiltInPlanner thinking).
    • text — from non-thought text parts (e.g. a final answer).
    • tool_call — from parts carrying a function_call (name, args, id); takes precedence over incidental text.
  • Read-only: never mutates input parts; skips parts with no mappable content; preserves order.
  • Self-contained: depends only on google-genai (transitively present via google-adk). No pyproject.toml dependency changes; flit already packages src/**. Registered in the top-level __init__.py alongside the other flat modules.
  • Ships with its own README.md and 21 unit tests.

Closes #162.

Why

Planner reasoning is currently encoded as thought=True plus inline /*PLANNING*/-style tags that every consumer has to re-parse. This gives them a stable, provider-agnostic typed view instead. Redirected from core ADK PR google/adk-python#6185 (closed; maintainer asked for it as a community module).

Testing Plan

  • Unit tests: added tests/unittests/planners/test_planner_content_blocks.py (21 tests) covering each block type, the PlanReActPlanner tag→reasoning_kind mapping, leading/trailing tag stripping, empty/redacted/unmappable parts being skipped, order preservation, the read-only guarantee (input parts unchanged, returned args is a copy), and round-trips through the real PlanReActPlanner.process_planning_response / BuiltInPlanner output.
  • Formatting/typing: isort (profile=google) and pyink (line-length 80) report clean on the new files; mypy (repo config) reports no issues on the src files.
$ pytest tests/unittests/planners/ -q
.....................                                                    [100%]
21 passed, 5 warnings in 0.31s

(The 5 warnings are pre-existing google-adk deprecation notices, unrelated to this change.)

Add a read-only, additive converter that turns planner-produced
google.genai.types.Part lists into LangChain v1-style typed content
blocks (reasoning / text / tool_call), so consumers can branch on a
typed discriminator instead of re-parsing inline /*PLANNING*/ tags.

The module is self-contained (depends only on google-genai) and ships
under google.adk_community.planners with its own README and unit tests.
Redirected from core adk-python (PR #6185) as a community module.
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.

Add standardized planner content blocks helper (community module)

1 participant