Repository navigation
Description
Self Checks
- I have read the Contributing Guide and Language Policy.
- This is only for bug report, if you would like to ask a question, please head to Discussions.
- I have searched for existing issues search for existing issues, including closed ones.
- I confirm that I am using English to submit this report, otherwise it will be closed.
- 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
- Please do not modify this template :) and fill in all the required fields.
Dify version
1.14.2 (root cause also present on main; latest commit to the affected file at time of writing: f15a8f02e)
Cloud or Self Hosted
Self Hosted (Docker / Kubernetes)
Steps to reproduce
- Self-host Dify 1.14.x.
- Create any non-workflow app — a Chatbot (basic or Agent mode) or a Completion app.
- Enable Langfuse tracing for that app (Monitoring → Tracing → Langfuse; public key, secret key, host).
- Send a chat message so a
messagerecord is produced. - Open the resulting trace in Langfuse.
✔️ Expected Behavior
The trace contains an llm generation observation carrying model + token usage, so Langfuse computes cost and latency — the same way Workflow / Advanced-Chat (chatflow) apps do.
❌ Actual Behavior
The trace has only the top-level message node — no child generation. Token counts appear only as plain fields inside the trace input payload (message_tokens, answer_tokens), not as a generation's usage. Because there is no generation observation, Total Cost is blank and Latency shows 0.00s. Workflow / Advanced-Chat (chatflow) apps are not affected.
Root cause
File: api/providers/trace/trace-langfuse/src/dify_trace_langfuse/langfuse_trace.py
message_trace() creates the trace (with id=trace_id) and then an llm generation — but the generation is built without an id:
langfuse_generation_data = LangfuseGeneration(
name="llm",
trace_id=trace_id,
start_time=trace_info.start_time,
...
# <-- no id= is passed
)
self.add_generation(langfuse_generation_data)LangfuseGeneration.id defaults to None. add_generation() then sends the event through the low-level ingestion API, and filter_none_values strips the None id:
data = filter_none_values(langfuse_generation_data.model_dump()) # drops the None "id"
body = CreateGenerationBody(id=data.get("id"), ...) # id is None
event = IngestionEvent_GenerationCreate(body=body, ...)
self.langfuse_client.api.ingestion.batch(batch=[event])So the generation event reaches Langfuse with no observation id and is dropped, while the trace (which has its own id) is accepted — hence "trace but no generation, no cost, 0.00s latency".
workflow_trace() is not affected because it always passes an explicit id:
node_generation_data = LangfuseGeneration(id=node_execution_id, ...)Why it regressed
Before 1.14 (e.g. 1.13.3), add_generation() used the high-level SDK, which auto-generates a client-side observation id when none is supplied:
self.langfuse_client.generation(**format_generation_data)The trace-provider refactor (#35144) / Langfuse v3-SDK migration switched to the raw ingestion API, which does not auto-generate an id — but message_trace was never updated to supply one. This broke generation export for every message_trace app type (Chatbot, Agent, Completion) from 1.14.0 onward, and it is still present on main.
Suggested fix
Pass an explicit id to the LangfuseGeneration created in message_trace (and to the other message-path observations in this file that currently omit it — suggested_question_trace, moderation_trace, dataset_retrieval_trace, tool_trace), e.g.:
langfuse_generation_data = LangfuseGeneration(
id=str(uuid.uuid4()),
name="llm",
trace_id=trace_id,
...
)Notes
- The same
MessageTraceInfoflow is shared by other trace providers (e.g. Opik), so it's worth checking whether they have the same missing-id pattern on their low-level ingestion paths. - Possibly related: Langfuse token counting error #35421 (incorrect token counts on the same
message_tracepath).
Activity
mengshun2022 commentedon Jul 13, 2026
I adopted this solution, explicitly adding
id=str(uuid.uuid4())during the creation ofLangfuseGenerationandLangfuseSpanin the project source code. However, in the evaluator function oflangfuse, I still cannot capture the node logs.dosubot commentedon Aug 13, 2026
Hi, @RazmikGevorgyan. I'm Dosu, and I'm helping the dify team manage their backlog and am marking this issue as stale.
Recap
0.00slatency in Langfuse.LangfuseGenerationandLangfuseSpan, but it did not resolve node log capture in Langfuse’s evaluator function.Next Steps
Thanks for your understanding and contribution.
brendangooden commentedon Sep 17, 2026
Hello — stepping in for @RazmikGevorgyan, I'm working with him on the same project.
Yes, this is still live. It reproduces on Dify
hotfix-1.17.0-fix.14(plugin-daemon0.6.10-local, Langfuse Python SDK v3) — three minor versions past 1.14.0. We believe #37833 is the right fix — can it please be reviewed, merged, and released ASAP? Adding a production repro below, plus a correction to the current scoping.Correction: advanced-chat / chatflow apps ARE affected. The recap here says "Workflow and advanced-chat apps do not appear to be affected." On our instance an advanced-chat (chatflow) app —
agent_based = false, and it carries aworkflow_run_id— emits a broken message trace on every turn. Dify traces each turn twice:workflow_run_id; node spans + pricedGENERATIONs) — correct; andmessage_id, with the sameconversation_idandworkflow_run_id) — 0 observations,totalCost = 0,latency = 0.The two are paired 1:1 by shared
conversation_id+workflow_run_id. So themessage_tracepath is broken independently of app type — it hits any app that produces message records, chatflows included, not just Chatbot / Agent / Completion.Scale. In a 100-trace sample, 80 were message-level traces; 41 (51%) had
totalCost = 0andlatency = 0— the broken half of each pair.Mechanism (redacted empty traces). Each has
status = normal,observations = 0(noGENERATION), and token counts only as plain fields in the trace input, never as a generation'susage:The paired workflow-run traces price their generations correctly on the same instance, so this is not a pricing/setup problem — it is isolated to the message-level trace, which is created without a generation observation id.
Impact. Real usage is large (tens of thousands of tokens per turn), but Langfuse reports $0 for ~half of all message traffic, so cost/latency dashboards structurally understate spend.
brendangooden commentedon Sep 25, 2026
@crazywoola @appleboy Any thoughts here?
41tair commentedon Nov 4, 2026
Fixed in #44673.