Enhance event handling for Crew, Task, and Event classes

- Add crew name to failed event types (CrewKickoffFailedEvent, CrewTrainFailedEvent, CrewTestFailedEvent)
- Update Task events to remove redundant task and context attributes
- Refactor EventListener to use Logger for consistent event logging
- Add new event types for Crew train and test events
- Improve event bus event tracking in test cases
This commit is contained in:
Lorenze Jay
2025-02-13 12:01:18 -08:00
parent 62a20426a5
commit 00a98cd5c9
9 changed files with 184 additions and 32 deletions

View File

@@ -1,4 +1,4 @@
from typing import Any
from typing import Any, Optional
from crewai.utilities.events.crew_events import CrewEvent
@@ -6,16 +6,15 @@ from crewai.utilities.events.crew_events import CrewEvent
class TaskStartedEvent(CrewEvent):
"""Event emitted when a task starts"""
task: Any
type: str = "task_started"
context: Optional[str]
model_config = {"arbitrary_types_allowed": True}
class TaskCompletedEvent(CrewEvent):
"""Event emitted when a task completes"""
task: Any
output: Any
type: str = "task_completed"