Standardize planner output as typed content blocks for PlanReActPlanner and BuiltInPlanner - #6666
Open
guptaishaan wants to merge 1 commit into
Open
Standardize planner output as typed content blocks for PlanReActPlanner and BuiltInPlanner#6666guptaishaan wants to merge 1 commit into
guptaishaan wants to merge 1 commit into
Conversation
…er and BuiltInPlanner Both `PlanReActPlanner` and `BuiltInPlanner` expose reasoning through Signed-off-by: Ishaan <ishaangupta0408@gmail.com>
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.
Both
PlanReActPlannerandBuiltInPlannerexpose reasoning throughtypes.Partobjects withthought=True, but callers had no standard wayto turn those parts into a provider-neutral format comparable to LangChain's
standard content blocks.
This PR adds a
to_content_blocks()method onBasePlannerthat convertsa list of
types.Partobjects into a list of typed dicts: thought partsbecome
{'type': 'reasoning', 'reasoning': '...'}and plain text partsbecome
{'type': 'text', 'text': '...'}. The method works for bothplanners because reasoning is already identified uniformly by the
thoughtflag on each part.Additionally,
PlanReActPlanner._mark_as_thought()now strips the leadingproprietary tags (
/*PLANNING*/,/*REASONING*/,/*ACTION*/,/*REPLANNING*/) from text before storing it, so callers that consume theraw parts — or the new
to_content_blocks()output — no longer need toparse those tags themselves.
Two new unit tests cover tag-stripping and the
to_content_blocks()contract.Fixes #3378