feat(planners): add standardized planner content blocks#163
Open
vaibhav-patel wants to merge 1 commit into
Open
feat(planners): add standardized planner content blocks#163vaibhav-patel wants to merge 1 commit into
vaibhav-patel wants to merge 1 commit into
Conversation
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.
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.
What
Adds
google.adk_community.planners— a read-only, additive helper that converts planner-producedgoogle.genai.types.Partlists into LangChain v1-style typed content blocks.parts_to_content_blocks(parts)/part_to_content_block(part)return typed blocks with atypediscriminator:reasoning— fromthought=Trueparts; carriesreasoningtext and areasoning_kind(planning/replanning/reasoning/action, derived fromPlanReActPlannerinline tags, orNoneforBuiltInPlannerthinking).text— from non-thought text parts (e.g. a final answer).tool_call— from parts carrying afunction_call(name,args,id); takes precedence over incidental text.google-genai(transitively present viagoogle-adk). Nopyproject.tomldependency changes; flit already packagessrc/**. Registered in the top-level__init__.pyalongside the other flat modules.README.mdand 21 unit tests.Closes #162.
Why
Planner reasoning is currently encoded as
thought=Trueplus 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
tests/unittests/planners/test_planner_content_blocks.py(21 tests) covering each block type, thePlanReActPlannertag→reasoning_kindmapping, leading/trailing tag stripping, empty/redacted/unmappable parts being skipped, order preservation, the read-only guarantee (input parts unchanged, returnedargsis a copy), and round-trips through the realPlanReActPlanner.process_planning_response/BuiltInPlanneroutput.isort(profile=google) andpyink(line-length 80) report clean on the new files;mypy(repo config) reports no issues on the src files.(The 5 warnings are pre-existing
google-adkdeprecation notices, unrelated to this change.)