Fix task planner matching plans to wrong tasks (issue #3953) #3954
+113
−4
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.
Summary
Fixes issue #3953 where the task planner was attaching plans to the wrong tasks when the LLM returned them out of order.
The Problem: The original implementation used
zip()to blindly pair tasks with plans, assuming they were in the same order. However, LLMs sometimes return plans in unexpected order (e.g., starting with "Task Number 21" instead of "Task Number 1"), causing plan mismatches.The Solution:
taskfieldChanges:
Crew._handle_crew_planning()to use task number extraction instead of positional matchingReview & Testing Checklist for Human
planning=Trueand 5-10 tasks to verify the regex patternr"Task Number (\d+)"correctly matches actual LLM outputs from the planning agentTest Plan
planning=Truecrew.kickoff()and verify each task receives the correct plan in its description_handle_crew_planning()to log the plan_map and verify task numbers are extracted correctlyNotes
CrewPlanner._create_tasks_summary()Link to Devin run: https://app.devin.ai/sessions/c96705b2147b411682a3b3d6339b4a13
Requested by: João (joao@crewai.com)