fix(api): defer streaming response until referenced variables are updated - #14
Conversation
| assigned_selector = self.node_data.assigned_variable_selector | ||
| return assigned_selector in variable_selectors |
There was a problem hiding this comment.
🔴 Type mismatch in blocks_variable_output causes comparison to always return False
The blocks_variable_output method in v1 VariableAssignerNode compares a Sequence[str] (list) directly with a set[tuple[str, ...]], which will always return False because a list is never equal to a tuple.
Click to expand
Bug Mechanism
The assigned_variable_selector is of type Sequence[str] (typically a list[str] from Pydantic parsing at node_data.py:14). The variable_selectors parameter is a set[tuple[str, ...]] (as defined in the base class at node.py:435 and populated in coordinator.py:172-175).
When checking assigned_selector in variable_selectors at line 43, Python compares a list with tuples in the set. Since ['conversation', 'conv_var'] != ('conversation', 'conv_var'), the comparison always returns False.
Comparison with v2 Implementation
The v2 implementation correctly handles this at v2/node.py:79:
item_selector_tuple = tuple(item.variable_selector)
if item_selector_tuple in variable_selectors:
return TrueImpact
The streaming response coordinator uses blocks_variable_output to determine if a node must complete before streaming can proceed. Because this method always returns False, the v1 Variable Assigner node will never block streaming output, potentially causing the Answer node to stream the old/default value of a conversation variable before the Variable Assigner has updated it.
Recommendation: Convert the assigned_selector to a tuple before comparison:
assigned_selector = tuple(self.node_data.assigned_variable_selector)
return assigned_selector in variable_selectorsWas this helpful? React with 👍 or 👎 to provide feedback.
Benchmark PR from qodo-benchmark#423