mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-04-07 19:48:13 +00:00
Some checks failed
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Nightly Canary Release / Check for new commits (push) Has been cancelled
Nightly Canary Release / Build nightly packages (push) Has been cancelled
Nightly Canary Release / Publish nightly to PyPI (push) Has been cancelled
threading.Thread() does not inherit the parent's contextvars.Context, causing ContextVar-based state (OpenTelemetry spans, Langfuse trace IDs, and any other request-scoped vars) to be silently dropped in async tasks. Fix by calling contextvars.copy_context() before spawning each thread and using ctx.run() as the thread target, which runs the function inside the captured context. Affected locations: - task.py: execute_async() — the primary async task execution path - utilities/streaming.py: create_chunk_generator() — streaming execution path Fixes: #4822 Related: #4168, #4286 Co-authored-by: Claude <noreply@anthropic.com>