Skip to content

fix(api): defer streaming response until referenced variables are updated#1

Open
tomerqodo wants to merge 3 commits into
coderabbit_full_base_fixapi_defer_streaming_response_until_referenced_variables_are_updated_pr1from
coderabbit_full_head_fixapi_defer_streaming_response_until_referenced_variables_are_updated_pr1
Open

fix(api): defer streaming response until referenced variables are updated#1
tomerqodo wants to merge 3 commits into
coderabbit_full_base_fixapi_defer_streaming_response_until_referenced_variables_are_updated_pr1from
coderabbit_full_head_fixapi_defer_streaming_response_until_referenced_variables_are_updated_pr1

Conversation

@tomerqodo

@tomerqodo tomerqodo commented Jan 30, 2026

Copy link
Copy Markdown

Benchmark PR from agentic-review-benchmarks#1

Summary by CodeRabbit

  • Bug Fixes

    • Improved variable assignment behavior in workflows when overwriting conversation variables.
    • Fixed variable output tracking to correctly reflect updated values in streaming mode.
  • Tests

    • Added test coverage for conversation variable overwrite functionality in streaming workflows.

@coderabbitai

coderabbitai Bot commented Jan 30, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Added a new blocks_variable_output method to VariableAssignerNode for checking blocked variable outputs, modified the _run method to conditionally use updated or input variable values based on write_mode, and introduced a corresponding YAML test fixture and test function for streaming conversation variable overwrite scenarios.

Changes

Cohort / File(s) Summary
Core Node Logic
api/core/workflow/nodes/variable_assigner/v1/node.py
Added public method blocks_variable_output() to check if assigned variable selector is in a provided set. Modified _run logic to use updated variable value when write_mode is CLEAR, otherwise use income value. Extended imports for Set and Tuple types.
Test Fixture & Test
api/tests/fixtures/workflow/test_streaming_conversation_variables_v1_overwrite.yml, api/tests/unit_tests/core/workflow/graph_engine/test_streaming_conversation_variables.py
Added YAML workflow fixture defining a streaming conversation variable with overwrite-mode assignment. Added corresponding test function test_streaming_conversation_variables_v1_overwrite_waits_for_assignment() to verify NodeRunStreamChunkEvent behavior for conversation variable updates.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A method hops in, checking paths with care,
Variables write clear or blend with flair,
Tests now stream with overwrite's might,
The fixture guides each workflow right! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is minimal and only states it is a 'Benchmark PR' without providing a substantive summary, context, or addressing the template requirements like issue linking and change summary. Provide a detailed summary of the changes, link to the associated issue using 'Fixes #<issue_number>', explain the motivation and context for the fix, and confirm completion of the checklist items.
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding deferred streaming response logic when referenced variables are updated in the VariableAssignerNode.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch coderabbit_full_head_fixapi_defer_streaming_response_until_referenced_variables_are_updated_pr1

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@tomerqodo

Copy link
Copy Markdown
Author

@coderabbitai review

1 similar comment
@tomerqodo

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jan 30, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@tomerqodo

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jan 30, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ravidqodo

Copy link
Copy Markdown

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Feb 2, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@api/core/workflow/nodes/variable_assigner/v1/node.py`:
- Around line 36-43: blocks_variable_output currently compares
self.node_data.assigned_variable_selector (a Sequence[str]) directly against
variable_selectors (a Set[Tuple[str, ...]]), which will never match; convert the
selector to a tuple before the membership test. Update the method
blocks_variable_output to compute something like
tuple(self.node_data.assigned_variable_selector) and check that against
variable_selectors so the set membership works as intended, leaving the rest of
the method and return semantics unchanged.

Comment on lines +36 to +43
def blocks_variable_output(self, variable_selectors: Set[Tuple[str, ...]]) -> bool:
"""
Check if this Variable Assigner node blocks the output of specific variables.

Returns True if this node updates any of the requested conversation variables.
"""
assigned_selector = self.node_data.assigned_variable_selector
return assigned_selector in variable_selectors

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n api/core/workflow/nodes/variable_assigner/v1/node.py | head -60

Repository: agentic-review-benchmarks/dify-combined-coderabbit

Length of output: 2571


🏁 Script executed:

# Search for assigned_variable_selector definition in the codebase
rg "assigned_variable_selector" --type py -B 2 -A 2

Repository: agentic-review-benchmarks/dify-combined-coderabbit

Length of output: 7839


🏁 Script executed:

# Find the class that contains this method and understand the node_data structure
ast-grep --pattern $'class $_ {
  $$$
  def blocks_variable_output(self, variable_selectors: Set[Tuple[str, ...]]) -> bool {
    $$$
  }
  $$$
}'

Repository: agentic-review-benchmarks/dify-combined-coderabbit

Length of output: 76


🏁 Script executed:

# Look at the node_data object definition
fd "node.py" api/core/workflow/nodes/variable_assigner --type f

Repository: agentic-review-benchmarks/dify-combined-coderabbit

Length of output: 199


🏁 Script executed:

rg "blocks_variable_output" --type py -B 3 -A 3

Repository: agentic-review-benchmarks/dify-combined-coderabbit

Length of output: 3467


🏁 Script executed:

# Check the node_data definition more thoroughly
cat -n api/core/workflow/nodes/variable_assigner/v1/node_data.py

Repository: agentic-review-benchmarks/dify-combined-coderabbit

Length of output: 577


🏁 Script executed:

# Look at variable_pool to understand how selectors are used
rg "variable_pool.get\|variable_pool.add" --type py -B 2 -A 2 | head -80

Repository: agentic-review-benchmarks/dify-combined-coderabbit

Length of output: 76


🏁 Script executed:

cat -n api/core/workflow/nodes/variable_assigner/v2/node.py | sed -n '36,50p'

Repository: agentic-review-benchmarks/dify-combined-coderabbit

Length of output: 846


🏁 Script executed:

# Check base class to understand the interface
cat -n api/core/workflow/nodes/base/node.py | sed -n '1,50p'

Repository: agentic-review-benchmarks/dify-combined-coderabbit

Length of output: 1967


🏁 Script executed:

# Look at how variable_selectors is constructed when calling blocks_variable_output
cat -n api/core/workflow/graph_engine/response_coordinator/coordinator.py | sed -n '1,100p'

Repository: agentic-review-benchmarks/dify-combined-coderabbit

Length of output: 4307


🏁 Script executed:

# Find where variable_selectors is constructed and passed to blocks_variable_output
rg "variable_selectors" api/core/workflow/graph_engine/response_coordinator/coordinator.py -B 5 -A 5

Repository: agentic-review-benchmarks/dify-combined-coderabbit

Length of output: 1202


🏁 Script executed:

# Check the actual v2 implementation to compare
cat -n api/core/workflow/nodes/variable_assigner/v2/node.py | sed -n '36,50p'

Repository: agentic-review-benchmarks/dify-combined-coderabbit

Length of output: 846


🏁 Script executed:

# Also check if there's any test that directly tests blocks_variable_output
rg "blocks_variable_output" api/tests --type py -B 5 -A 5

Repository: agentic-review-benchmarks/dify-combined-coderabbit

Length of output: 1550


🏁 Script executed:

cat -n api/core/workflow/nodes/variable_assigner/v2/node.py | head -60

Repository: agentic-review-benchmarks/dify-combined-coderabbit

Length of output: 2775


🏁 Script executed:

# Search for assigned_variable_selector definition in v2
rg "assigned_variable_selector" api/core/workflow/nodes/variable_assigner/v2/ -B 2 -A 2

Repository: agentic-review-benchmarks/dify-combined-coderabbit

Length of output: 76


🏁 Script executed:

cat -n api/core/workflow/nodes/variable_assigner/v2/node.py | sed -n '65,85p'

Repository: agentic-review-benchmarks/dify-combined-coderabbit

Length of output: 1085


🏁 Script executed:

# Check the v2 node_data definition
cat -n api/core/workflow/nodes/variable_assigner/v2/entities.py | head -50

Repository: agentic-review-benchmarks/dify-combined-coderabbit

Length of output: 1208


Convert assigned_variable_selector to tuple for set membership check.

assigned_variable_selector is typed as Sequence[str] but variable_selectors is Set[Tuple[str, ...]]. A sequence will never match a tuple in the membership check, so this method will always return False. Convert the selector to a tuple before comparison.

Suggested fix
-        assigned_selector = self.node_data.assigned_variable_selector
-        return assigned_selector in variable_selectors
+        assigned_selector = tuple(self.node_data.assigned_variable_selector)
+        return assigned_selector in variable_selectors
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def blocks_variable_output(self, variable_selectors: Set[Tuple[str, ...]]) -> bool:
"""
Check if this Variable Assigner node blocks the output of specific variables.
Returns True if this node updates any of the requested conversation variables.
"""
assigned_selector = self.node_data.assigned_variable_selector
return assigned_selector in variable_selectors
def blocks_variable_output(self, variable_selectors: Set[Tuple[str, ...]]) -> bool:
"""
Check if this Variable Assigner node blocks the output of specific variables.
Returns True if this node updates any of the requested conversation variables.
"""
assigned_selector = tuple(self.node_data.assigned_variable_selector)
return assigned_selector in variable_selectors
🤖 Prompt for AI Agents
In `@api/core/workflow/nodes/variable_assigner/v1/node.py` around lines 36 - 43,
blocks_variable_output currently compares
self.node_data.assigned_variable_selector (a Sequence[str]) directly against
variable_selectors (a Set[Tuple[str, ...]]), which will never match; convert the
selector to a tuple before the membership test. Update the method
blocks_variable_output to compute something like
tuple(self.node_data.assigned_variable_selector) and check that against
variable_selectors so the set membership works as intended, leaving the rest of
the method and return semantics unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants