Fix: Set crew attribute on planning agent to prevent EventBus errors #3783
+40
−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.
Fix: Set crew attribute on planning agent to prevent EventBus errors
Summary
Fixes issue #3782 where the planning agent created by
CrewPlannerdidn't have itscrewattribute set, causing EventBus errors like'NoneType' object has no attribute 'key'when telemetry tried to accesstask.agent.crew.key.Root cause: In
CrewPlanner._create_planning_agent(), the agent was created without setting itscrewattribute, unlike regular agents which get their crew set inCrew.kickoff()(line 692). When the planning task executes, event handlers try to accessagent.crew.key, which fails.Fix:
CrewPlannerconstructorChanges:
CrewPlanner.__init__: Added optionalcrewparameterCrewPlanner._create_planning_agent: Setsplanning_agent.crew = self.crewif crew is providedCrew._handle_crew_planning: Passescrew=selfto CrewPlannertest_planning_agent_has_crew_attributeto verify the fixInternalCrewPlannertoTestCrewPlanner(pytest convention)Review & Testing Checklist for Human
planning=True, execute it, and verify the EventBus error mentioned in [BUG] planning_agent创建的时候为什么没有指定crew,导致了后面流程中使用crew的时候报错了 #3782 no longer occursif self.crew: planning_agent.crew = self.crewlines inplanning_handler.pyand confirm the new test failsCrew._handle_crew_planning)planning=Trueand verify no regressions in planning behaviorNotes
test_create_tasks_summary_with_knowledge_and_tools(unrelated to this PR - chromadb mock issue)InternalCrewPlannertoTestCrewPlannerto fix pytest discoveryuv.lockduring testing (it was corrupted), but restored it from git - should be clean nowSession: https://app.devin.ai/sessions/35dc88450fa54b8d9ca784bfab6dc3b4
Requested by: João ([email protected])