You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
agent-chat app mode missing app_id in trace metadata (Langfuse/OTLP integrations can't identify the app) #38795
Traces from agent-chat apps don't include app_id in their metadata, while advanced-chat apps do. This breaks third-party tracing integrations (Langfuse, LangSmith, Opik, etc.) that rely on app_id to identify which Dify app generated a trace.
Environment
Dify version: 1.13.3
App mode: agent-chat (Agent)
Tracing provider: Langfuse
Reproduction
Create two apps — one advanced-chat, one agent-chat
Enable Langfuse tracing for both (identical config)
Send a chat request to each app
Inspect the trace metadata in Langfuse
Expected: Both traces contain app_id in metadata.
Actual: Only the advanced-chat trace has app_id. The agent-chat trace is missing it.
Root cause
In api/core/ops/ops_trace_manager.py, the WorkflowTraceInfo metadata (used for advanced-chat) explicitly includes app_id:
Any tracing integration that uses app_id from trace metadata to identify the source app will fail for agent-chat apps. This affects all trace providers that read app_id from trace_info.metadata (LangSmith, Opik, Weave, Tencent, Arize Phoenix all have this pattern in their trace implementations).
Suggested fix
Add app_id to the MessageTraceInfo metadata by fetching it from the Conversation table (which already has an app_id column). The conversation is already queried for mode — just extend the query.
I looked into the current code in api/core/ops/ops_trace_manager.py and it appears that app_idis already included in the MessageTraceInfo metadata. Specifically, it's sourced from message_data.app_id (the Message model has a direct app_id field) [1]. The WorkflowTraceInfo metadata similarly includes app_id from workflow_run.app_id[2].
There doesn't appear to be any conditional logic that would exclude app_id for agent-chat vs advanced-chat — the metadata construction is uniform for all app types [3].
A few possibilities to investigate:
Version mismatch — This fix may have already been applied after 1.13.3. Could you check which exact commit/tag you're running? The current main branch appears to include app_id in MessageTraceInfo.
Message record issue — It's possible that for agent-chat apps, the Message record's app_id field isn't being populated correctly at creation time in your version.
Trace provider implementation — Some trace providers (Langfuse, LangSmith, etc.) have their own trace methods that might selectively read fields from trace_info.metadata. It's worth checking whether the provider-specific implementation in your version passes through app_id.
Could you confirm whether you're running the latest code or a specific release? If you're on an older version, this may already be resolved upstream.
This appears to be resolved on current main: TraceTask.message_trace in api/core/ops/ops_trace_manager.py, which builds traces for agent-chat and the other message-based modes, now includes "app_id": message_data.app_id in the metadata, next to tenant_id, app_name and workspace_name. It was added in #33138. Message.app_id is a required column, so it is always set. The PR linked here (#39163) was closed only for merge conflicts. If you still see a missing app_id on a current build, a trace example would help; otherwise this can probably be closed.
Activity
dosubot commentedon Jul 12, 2026
Hi @rainbow0432-dev! I'm Dosu and I'm helping the Dify team.
I looked into the current code in
api/core/ops/ops_trace_manager.pyand it appears thatapp_idis already included in theMessageTraceInfometadata. Specifically, it's sourced frommessage_data.app_id(theMessagemodel has a directapp_idfield) [1]. TheWorkflowTraceInfometadata similarly includesapp_idfromworkflow_run.app_id[2].There doesn't appear to be any conditional logic that would exclude
app_idfor agent-chat vs advanced-chat — the metadata construction is uniform for all app types [3].A few possibilities to investigate:
mainbranch appears to includeapp_idinMessageTraceInfo.Messagerecord'sapp_idfield isn't being populated correctly at creation time in your version.trace_info.metadata. It's worth checking whether the provider-specific implementation in your version passes throughapp_id.Could you confirm whether you're running the latest code or a specific release? If you're on an older version, this may already be resolved upstream.
To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
rdydygin commentedon Oct 27, 2026
This appears to be resolved on current
main:TraceTask.message_traceinapi/core/ops/ops_trace_manager.py, which builds traces foragent-chatand the other message-based modes, now includes"app_id": message_data.app_idin the metadata, next totenant_id,app_nameandworkspace_name. It was added in #33138.Message.app_idis a required column, so it is always set. The PR linked here (#39163) was closed only for merge conflicts. If you still see a missingapp_idon a current build, a trace example would help; otherwise this can probably be closed.