mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-04-12 05:52:39 +00:00
First-time users have is_tracing_enabled_in_context() = False by design (it's a prerequisite for should_auto_collect_first_time_traces). This caused _initialize_backend_batch to return early without creating the batch, and _send_events_to_backend to send to a non-existent batch. Add skip_context_check parameter to _initialize_backend_batch so the first-time handler can bypass the guard during deferred init. Gate backend_initialized on trace_batch_id being set. Call _finalize_backend_batch directly instead of finalize_batch (which has the same context guard). Sync is_current_batch_ephemeral on success to prevent endpoint mismatch between batch creation and event send.