fix(api): defer streaming response until referenced variables are updated#27
Conversation
WalkthroughThis change introduces variable output blocking logic to the VariableAssignerNode and refines how input values are prepared based on write mode (CLEAR versus other modes). A new test fixture and test case validate the overwrite behavior in streaming conversation variable scenarios. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@api/core/workflow/nodes/variable_assigner/v1/node.py`:
- Around line 36-43: The blocks_variable_output method is using
self.node_data.assigned_variable_selector (a list) to check membership against
variable_selectors (a Set[Tuple[str, ...]]), so it always returns False; fix by
normalizing the assigned selector to a tuple before lookup (e.g., create
tuple(self.node_data.assigned_variable_selector) and check that against
variable_selectors) in the blocks_variable_output function so the membership
test works as intended.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
api/core/workflow/nodes/variable_assigner/v1/node.pyapi/tests/fixtures/workflow/test_streaming_conversation_variables_v1_overwrite.ymlapi/tests/unit_tests/core/workflow/graph_engine/test_streaming_conversation_variables.py
🧰 Additional context used
🧬 Code graph analysis (1)
api/core/workflow/nodes/variable_assigner/v1/node.py (2)
api/core/workflow/nodes/base/node.py (2)
blocks_variable_output(435-445)node_data(535-537)api/core/workflow/nodes/variable_assigner/v2/node.py (1)
blocks_variable_output(70-85)
🔇 Additional comments (4)
api/core/workflow/nodes/variable_assigner/v1/node.py (2)
2-2: No issues with typing import change.
102-111: Clear-mode input value handling looks correct.api/tests/unit_tests/core/workflow/graph_engine/test_streaming_conversation_variables.py (1)
50-77: Solid coverage for overwrite streaming behavior.api/tests/fixtures/workflow/test_streaming_conversation_variables_v1_overwrite.yml (1)
1-158: Fixture looks consistent with overwrite streaming scenario.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
| 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 |
There was a problem hiding this comment.
Normalize selector to tuple before set lookup.
assigned_variable_selector is a list, while variable_selectors is a Set[Tuple[str, ...]], so membership will always be False and blocking won’t occur. Convert the selector to a tuple before checking.
🔧 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🤖 Prompt for AI Agents
In `@api/core/workflow/nodes/variable_assigner/v1/node.py` around lines 36 - 43,
The blocks_variable_output method is using
self.node_data.assigned_variable_selector (a list) to check membership against
variable_selectors (a Set[Tuple[str, ...]]), so it always returns False; fix by
normalizing the assigned selector to a tuple before lookup (e.g., create
tuple(self.node_data.assigned_variable_selector) and check that against
variable_selectors) in the blocks_variable_output function so the membership
test works as intended.
Benchmark PR from agentic-review-benchmarks#1
Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.