Attach call recordings to Langfuse traces - #242
Merged
Merged
Conversation
markbackman
force-pushed
the
mb/langfuse-recording
branch
from
August 14, 2026 20:29
f96dca0 to
a8e4dda
Compare
markbackman
force-pushed
the
mb/langfuse-recording
branch
from
August 15, 2026 00:39
a8e4dda to
5cccce1
Compare
The bot's audio buffer processor feeds a recorder that uploads through the Langfuse media API once the pipeline has shut down: the whole call on the trace root, stereo with the user left and the bot right, and each turn's user and bot audio on that turn's span as its input and output. Media does not travel over OTLP and is linked to a trace by id, so the upload happens after the conversation ends and costs it nothing. The keys and host come from the OTLP exporter's own configuration, which puts the audio in the same Langfuse project as the spans.
markbackman
force-pushed
the
mb/langfuse-recording
branch
from
August 15, 2026 19:22
5cccce1 to
e8a8007
Compare
jamsea
approved these changes
Aug 17, 2026
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Adds call recording to the Langfuse example. Each call's audio is attached to its trace, giving two levels of playback in the Langfuse UI:
turnspan — the user's speech as the span'sinput, the bot's reply as itsoutput.Langfuse media travels over the REST media API rather than OTLP and is linked to a trace by id, so everything uploads after the pipeline has shut down and the call itself pays nothing for it.
langfuse_recording.pyholds the integration and uses only public Pipecat API, so it can be lifted into another bot as a single file. Wiring it up is anAudioBufferProcessorin the pipeline plus three calls:Credentials are read from
OTEL_EXPORTER_OTLP_HEADERSand the host fromOTEL_EXPORTER_OTLP_ENDPOINT, since Langfuse authenticates its OTLP endpoint with the same key pair the REST API wants. Media and spans therefore reach the same project by construction, with no second pair of environment variables to keep in sync.LANGFUSE_PUBLIC_KEY/LANGFUSE_SECRET_KEY/LANGFUSE_HOSToverride it for a self-hosted media deployment.Depends on unreleased pipecat
The recording needs
pcm_to_wav()(pipecat-ai/pipecat#5326, merged) and per-turn turn audio events (pipecat-ai/pipecat#5329, open). Until both are in a release,pyproject.tomlpinspipecat-aito a local checkout through[tool.uv.sources]; that section and its comment come out when they ship.This replaces #240, which took the same feature through a helper in pipecat core.
Testing
uv run bot.pyand open the trace in Langfuse; the players appear on the trace root and on each turn span.