Skip to content

fix(planners): handle leading whitespace before PlanReActPlanner tags - #8529

Open
nizamudheenti wants to merge 1 commit into
google:mainfrom
nizamudheenti:fix/plan-react-leading-whitespace-tags
Open

nizamudheenti wants to merge 1 commit into
google:mainfrom
nizamudheenti:fix/plan-react-leading-whitespace-tags

Conversation

@nizamudheenti

Copy link
Copy Markdown

Fixes #8528

Summary

  • Check response_text.lstrip().startswith(self._PLANNING_TAGS) in PlanReActPlanner._handle_non_function_call_parts (src/google/adk/planners/plan_re_act_planner.py) so leading whitespace/newlines emitted by LLMs before /*PLANNING*/, /*REASONING*/, /*ACTION*/, or /*REPLANNING*/ do not leak raw internal ReAct tags into user-visible text.
  • Preserves existing behavior for non-thought parts that start with normal prose before a stray tag.

Testing Plan

  • Added test_leading_whitespace_before_planning_tag_is_marked_as_thought in tests/unittests/planners/test_plan_re_act_planner.py.
  • Verified the new test fails before the fix (thought remained None with raw /*PLANNING*///*ACTION*/ intact) and passes after:
    • pytest tests/unittests/planners/test_plan_re_act_planner.py -q -> 9 passed
    • ruff check src/google/adk/planners/plan_re_act_planner.py tests/unittests/planners/test_plan_re_act_planner.py -> All checks passed

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.

planners: PlanReActPlanner leaks raw planning tags when LLM output has leading whitespace

1 participant