mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-04-13 22:42:37 +00:00
fix(tracing): route action-event batch init through _initialize_batch to respect use_ephemeral
_handle_action_event called batch_manager.initialize_batch() directly, defaulting use_ephemeral=False. When a DefaultEnvEvent fired before CrewKickoffStartedEvent in the thread pool, the batch was locked in as non-ephemeral, causing VCR cassette path mismatches on CI. Route through _initialize_batch() which computes use_ephemeral from _check_authenticated().
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from datetime import datetime, timezone
|
||||
import logging
|
||||
import uuid
|
||||
import webbrowser
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from rich.console import Console
|
||||
from rich.panel import Panel
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import time
|
||||
from dataclasses import dataclass, field
|
||||
from datetime import datetime, timezone
|
||||
from logging import getLogger
|
||||
from threading import Condition, Lock
|
||||
import time
|
||||
from typing import Any
|
||||
import uuid
|
||||
|
||||
@@ -114,10 +114,10 @@ class TraceBatchManager:
|
||||
"""Send batch initialization to backend"""
|
||||
|
||||
if not skip_context_check and not is_tracing_enabled_in_context():
|
||||
return
|
||||
return None
|
||||
|
||||
if not self.plus_api or not self.current_batch:
|
||||
return
|
||||
return None
|
||||
|
||||
try:
|
||||
payload = {
|
||||
@@ -167,14 +167,14 @@ class TraceBatchManager:
|
||||
f"Error initializing trace batch: {e}. Continuing without tracing."
|
||||
)
|
||||
self.trace_batch_id = None
|
||||
return
|
||||
return None
|
||||
|
||||
if response is None:
|
||||
logger.warning(
|
||||
"Trace batch initialization failed gracefully. Continuing without tracing."
|
||||
)
|
||||
self.trace_batch_id = None
|
||||
return
|
||||
return None
|
||||
|
||||
# Fall back to ephemeral on auth failure (expired/revoked token)
|
||||
if response.status_code in [401, 403] and not use_ephemeral:
|
||||
|
||||
@@ -780,7 +780,7 @@ class TraceCollectionListener(BaseEventListener):
|
||||
"crew_name": getattr(source, "name", "Unknown Crew"),
|
||||
"crewai_version": get_crewai_version(),
|
||||
}
|
||||
self.batch_manager.initialize_batch(user_context, execution_metadata)
|
||||
self._initialize_batch(user_context, execution_metadata)
|
||||
|
||||
self.batch_manager.begin_event_processing()
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user