Repository navigation
Conversation
A variable whose source ran with streaming disabled produces no incremental chunks - only an empty final marker in the stream buffer. _read_variable_chunks popped that marker, treated the closed buffer as a complete stream, and skipped the variable-pool fallback (which only ran when the buffer had no events at all). The response node therefore rendered nothing for non-streamed variables, even though the workflow run record contained the text. Reported from dify (langgenius/dify#46034). Fall back to the variable pool when the buffer closed without emitting any non-empty text. Streamed variables are unaffected: meaningful chunks suppress the fallback.
|
All contributors on this pull request have signed the CLA. |
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
Member
|
Thanks for looking into this! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #389 (root cause of langgenius/dify#46034)
Problem
When a variable's source node runs with streaming disabled, the stream buffer receives only an empty final marker (
chunk="",is_final=True) and is closed.TemplateStream._read_variable_chunkspops the marker, seesis_closed, marks the segment complete — and skips the variable-pool fallback, because that branch requiresnot has_stream_eventswhile the buffer does have events (the empty marker).The response node therefore renders nothing for non-streamed variables, even though the workflow run record contains the text. Reported from dify as langgenius/dify#46034 (the 0.8.0 rev dify pins has the same logic in
filter.py;maincarries it intemplate_stream.py).Fix
Track the text actually emitted for the segment; if the closed buffer carried no non-empty content, fall back to the variable-pool value as before.
Streamed variables are unaffected: meaningful chunks suppress the fallback (
test_response_stream_filter_no_pool_fallback_when_streamedpins this). Genuinely empty values render nothing, as before.Tests
test_response_stream_filter_falls_back_to_pool_for_non_streamed_variable— fails before the fix (rendered""), passes after ("saved").test_response_stream_filter_no_pool_fallback_when_streamed— guards against double-emission for streamed variables.pytest tests/engine/: 166 passed.Note for the dify side
dify pins graphon at rev
4fa2214; after this merges, a rev bump in dify'spyproject.tomlpicks the fix up.