Description
The Langfuse OTEL SDK (v4) logs Failed to detach context errors during orchestrator runs. This occurs when OpenTelemetry span context tokens are created in one async context and reset in another — a mismatch caused by LangGraph's node execution model.
Log Output
Failed to detach context
Traceback (most recent call last):
File "...\opentelemetry\context\__init__.py", line 155, in detach
_RUNTIME_CONTEXT.detach(token)
File "...\opentelemetry\context\contextvars_context.py", line 53, in detach
self._current_context.reset(token)
ValueError: <Token ...> was created in a different Context
Observed on every task run — appears once per run, consistently during the QA or flush_memory phase.
Impact
- Cosmetic only — traces still record correctly in Langfuse (confirmed via trace JSON export)
- Clutters FastAPI logs and may mask real errors
- No data loss or functional impact
Possible Fixes
- Suppress the warning — catch
ValueError on context detach and log at DEBUG level
- Langfuse SDK config — check if there's an OTEL context propagation setting for async frameworks
- Upstream fix — may be resolved in a future
opentelemetry-sdk or langfuse release
Related
Also see: Unknown observation type: event, falling back to span (filed as separate issue) — both are Langfuse/OTEL integration noise.
Description
The Langfuse OTEL SDK (v4) logs
Failed to detach contexterrors during orchestrator runs. This occurs when OpenTelemetry span context tokens are created in one async context and reset in another — a mismatch caused by LangGraph's node execution model.Log Output
Observed on every task run — appears once per run, consistently during the QA or flush_memory phase.
Impact
Possible Fixes
ValueErroron context detach and log at DEBUG levelopentelemetry-sdkorlangfusereleaseRelated
Also see:
Unknown observation type: event, falling back to span(filed as separate issue) — both are Langfuse/OTEL integration noise.