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
fix(tracing): retain chatflow inputs for suggested questions - #45387
Chatflow messages can contain a user query while their stored model-prompt field is empty. Suggested-question trace assembly reads only that prompt field, so tracing providers receive an empty input even though the authorized message already contains the query.
Preserve recorded model prompts and fall back to the persisted user query inside the existing owner-scoped read. Generated questions, timings, correlation, and stored message data keep their existing behavior. The regression cases use real SQLite-backed messages, including empty string, list, and object prompts and an existing nonempty chat prompt.
This is based on main after #44673. It only changes input selection in shared record assembly; the proposed query fallback supplies context for the auxiliary tool span and does not reconstruct the actual suggestion-model prompt.
Chatflow: empty model prompts, nonempty user query
Empty suggested-question trace input
Persisted user query
Chat: recorded model prompts
Recorded prompts
Same recorded prompts
Validation
New regression cases against unchanged main: 3 failed, 1 passed; all failures reproduce the missing chatflow input.
make test TARGET_TESTS="api/tests/unit_tests/repositories/test_trace_record_repository.py api/tests/unit_tests/services/tracing api/providers/trace/trace-aliyun/tests/unit_tests api/providers/trace/trace-sdk/tests/unit_tests": 527 passed.
Full make lint && make type-check on d5f610c: passed, with no PATH_TO_CHECK restriction. Type checking includes the backend, configured unit tests, and container tests.
Full lint left 4,393 files unchanged, passed the AST guards and dotenv checks, reported 762 valid / 0 mismatched response contracts, and kept 82 import contracts / 0 broken.
The 527-test regression suite was rerun successfully after installing the lockfile's default and development dependency sets.
Before/after persisted-record replay through the canonical builder and native Aliyun OTLP exporter, followed by monitoring-backend readback: 10 spans / 2 traces per side, unchanged parent relationships and fixture token usage; both suggested-question inputs change from empty to the saved query. This is a trace-pipeline replay with synthetic records, not a live model invocation or a full Web E2E.
Checklist
This change requires a documentation update in Dify Docs.
There is an associated issue, linked with Fixes #45384.
I understand that this PR may be closed in case there was no previous discussion or issues.
I verified the change and added regression coverage.
The inline contract documents the fallback and unchanged source-error behavior.
I ran the full make lint && make type-check for the backend. Frontend checks are not applicable; no frontend files changed.
@41tair could you clarify why this was closed and what you would like adjusted before resubmission?
This was based on main after #44673. That refactor handles trace structure/correlation and represents suggested questions as auxiliary tool spans. This PR only changes shared record assembly: preserve message.message when present, otherwise use the already-authorized message's persisted query. The proposed fallback supplies context for the auxiliary span; it does not reconstruct the actual suggestion-model prompt.
I have now completed the full backend checks on the unchanged commit d5f610c, and updated the PR description:
make lint: passed; 4,393 files unchanged and 82 import contracts kept.
make type-check: passed without PATH_TO_CHECK, including the configured backend, unit-test and container-test checks.
Trace repository/pipeline/Aliyun/SDK regression suite: 527 passed again with the lockfile's default and development dependencies installed.
Is the query fallback appropriate for this auxiliary span, or would you prefer capturing its actual generation inputs in the event? I can adjust the implementation, coverage, or submission format based on your guidance. The related issue is #45384.
This PR only adds the suggested-question query fallback on top of #44673; full make lint && make type-check and all 527 tracing regression tests pass locally. My account does not have permission to reopen it. @41tair could you reopen it for review, or point out what needs changing first?
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
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
Chatflow messages can contain a user query while their stored model-prompt field is empty. Suggested-question trace assembly reads only that prompt field, so tracing providers receive an empty input even though the authorized message already contains the query.
Preserve recorded model prompts and fall back to the persisted user query inside the existing owner-scoped read. Generated questions, timings, correlation, and stored message data keep their existing behavior. The regression cases use real SQLite-backed messages, including empty string, list, and object prompts and an existing nonempty chat prompt.
This is based on main after #44673. It only changes input selection in shared record assembly; the proposed query fallback supplies context for the auxiliary tool span and does not reconstruct the actual suggestion-model prompt.
Fixes #45384.
Before / after
Validation
make test TARGET_TESTS="api/tests/unit_tests/repositories/test_trace_record_repository.py api/tests/unit_tests/services/tracing api/providers/trace/trace-aliyun/tests/unit_tests api/providers/trace/trace-sdk/tests/unit_tests": 527 passed.make lint && make type-checkond5f610c: passed, with noPATH_TO_CHECKrestriction. Type checking includes the backend, configured unit tests, and container tests.Checklist
Fixes #45384.make lint && make type-checkfor the backend. Frontend checks are not applicable; no frontend files changed.From Codex