mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-04-07 19:48:13 +00:00
ThreadPoolExecutor threads do not inherit the calling thread's contextvars context, causing _event_id_stack and _current_celery_task_id to be empty in worker threads. This broke OTel span parenting for parallel tool calls (missing parent_event_id) and lost the Celery task ID in the enterprise tracking layer ([Task ID: no-task]). Fix by capturing an independent context copy per submission via contextvars.copy_context().run in CrewAgentExecutor._handle_native_tool_calls, so each worker thread starts with the correct inherited context without sharing mutable state across threads.