From e3026ebd56bac508028dd0160e6a2e84f4fc5c25 Mon Sep 17 00:00:00 2001 From: Eduardo Chiarotti Date: Mon, 10 Feb 2025 11:50:54 -0300 Subject: [PATCH] feat: add add task traces function --- src/crewai/traces/unified_trace_controller.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/crewai/traces/unified_trace_controller.py b/src/crewai/traces/unified_trace_controller.py index e2bea0edf..f9d59c937 100644 --- a/src/crewai/traces/unified_trace_controller.py +++ b/src/crewai/traces/unified_trace_controller.py @@ -80,6 +80,19 @@ class UnifiedTraceController: self.flow_step = flow_step self.status: str = "running" + def _add_to_task_traces(self) -> None: + """Add this trace to the task's trace collection.""" + if not hasattr(UnifiedTraceController, "_task_traces"): + UnifiedTraceController._task_traces = {} + + if self.task_id is None: + return + + if self.task_id not in UnifiedTraceController._task_traces: + UnifiedTraceController._task_traces[self.task_id] = [] + + UnifiedTraceController._task_traces[self.task_id].append(self) + @classmethod def get_task_traces(cls, task_id: str) -> List["UnifiedTraceController"]: """Get all traces for a specific task.