fix(planners): keep all leading parallel function calls#6141
Open
nyxst4ck wants to merge 1 commit into
Open
Conversation
PlanReActPlanner.process_planning_response guarded the trailing parallel-call collection loop with `if first_fc_part_index > 0`, but first_fc_part_index is the index of the first function call (initialized to -1). When the model response *begins* with a function call the index is 0, so the guard was false and every parallel function call after the first was silently dropped. Responses that start with text (index >= 1) were unaffected, which is why this went unnoticed. Use `>= 0` so the first part being a function call is handled too. Adds unit tests for both the leading-call and leading-text cases.
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.
Link to Issue or Description of Change
No existing issue — describing the bug here.
Problem:
PlanReActPlanner.process_planning_responsedrops every parallel function callexcept the first when the model's response starts with a function call.
The trailing-group collector is guarded by:
first_fc_part_indexis the index of the first function call (sentinel-1).When the first part is a function call its index is
0, so> 0is false andthe loop that collects the rest of the parallel call group never runs — the
first call is kept, the rest are silently dropped. Responses that begin with
text (index
>= 1) work, which is why this wasn't noticed. Gemini emitting agroup of parallel function calls as the first parts of a turn is a realistic
case (and is what the planner instruction encourages).
Solution:
Change the guard to
>= 0so a leading function call is handled the same as onepreceded by text.
Testing Plan
Unit Tests:
tests/unittests/planners/test_plan_re_act_planner.py.test_preserves_all_leading_parallel_function_callsis red onmain(returns only
["get_weather"]) and green with this change (returns["get_weather", "get_time"]). A companion test confirms the leading-text casestill works.
pyink + isort clean.
Checklist