mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-04-06 02:58:13 +00:00
Use contextvars.copy_context() to capture the calling thread's context and run the worker thread target via ctx.run() so that ContextVar values (used by OpenTelemetry, Langfuse, and other tracing libraries) are preserved inside async task execution threads. Previously, threading.Thread() was used without copying context, causing all ContextVar values to silently reset to defaults in worker threads. Fixes #4822 Co-Authored-By: João <joao@crewai.com>