agents icon indicating copy to clipboard operation
agents copied to clipboard

Can't set prompt name and prompt version on an `llm_request` generation inside of the `llm_node` function

Open rbl-timuvlad opened this issue 2 months ago • 0 comments

Goal: I want to be able to link generations to prompts in Langfuse using Livekit Agents.

What I tried: When using a STT->LLM-TTS and overriding the llm_node function I use the following code to set the prompt name and prompt version for observability

current_span = trace.get_current_span()
        if current_span:
            current_span.set_attributes(
                {
                    "langfuse.observation.prompt.name": self._app_settings.system_prompt_name,
                    "langfuse.observation.prompt.version": self._app_settings.system_prompt_version,
                }
            )

although this correctly sets the prompt name and version on the llm_node span, Langfuse won't link that span to the specified prompt because it can only do that with generations (as per documentation https://langfuse.com/docs/prompt-management/get-started#link-with-langfuse-tracing-optional) and not spans.

Question: Has anyone else stumbled on this? How did you solve it?

rbl-timuvlad avatar Nov 12 '25 15:11 rbl-timuvlad