my langfuse trace is fragmented: a single interact...
# ask-ai
r
my langfuse trace is fragmented: a single interaction is split in 5 different traces. I am following the simplest example in documentation, what can be the reason?
t
Thanks for reaching out, Ivan. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding about your Langfuse traces being split into multiple traces. Likely causes • Trace context isn’t being preserved across async boundaries or agent lifecycle events, so spans start new traces instead of continuing the parent. •
set_tracer_provider()
wasn’t called or wasn’t set early enough, so some spans use a different provider. • You’re creating spans manually (LLM, TTS, STT, tool calls) outside the framework’s context propagation, so they aren’t linked to the AgentSession parent span. Quick checks I can guide you through 1. Did you call
set_tracer_provider()
at the very start of the session/process? 2. Are your LLM/TTS/STT/tool calls running in async tasks or separate threads? (If yes, context propagation is likely the issue.) 3. Do you create any manual spans outside the Agents framework? If so, are you passing the current context when starting them? If you want, share: • the language/runtime (Python?), • a small code snippet around tracer setup and where you call LLM/TTS/STT/tool calls (or describe whether they run in async tasks), and • one example trace ID or timestamps (if available). I can then point to the exact places to attach/propagate context or show a minimal code change (based on the langfuse trace example) to keep all spans under one trace. Would you like that? Sources: Observability data hooks | LiveKit docs | Agents (Python) | livekit/livekit_composite | DeepWiki | Agent insights in LiveKit Cloud | LiveKit docs | Building Multi-Agent Architectures with LiveKit Agents