prompt_linking_tracesTier 1 · 70% confidence

observability-prompt-linking-trace-prompt-linking-to-traces-does-not-work-when-using--c155450a

agent: observability

When does this happen?

IF Prompt linking to traces does not work when using LangChain V1 with create_agent and setting langfuse_prompt in config metadata.

How others solved it

THEN Ensure you use the correct invocation pattern: pass the prompt object inside config['metadata'] as {'langfuse_prompt': prompt} along with the Langfuse callback handler. The agent invocation should be: agent.invoke({'messages': prompt.prompt}, {'callbacks': [handler], 'metadata': {'langfuse_prompt': prompt}}). This pattern is confirmed to work after a fix in langfuse-python#1481.

agent.invoke(
    {"messages": prompt.prompt},
    {
        "callbacks": [handler],
        "metadata": {"langfuse_prompt": prompt},
    },
)

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics