Skip to content

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

Open
tomerqodo wants to merge 3 commits intocoderabbit_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#27
tomerqodo wants to merge 3 commits intocoderabbit_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
Copy link

@tomerqodo tomerqodo commented Jan 29, 2026

Benchmark PR from agentic-review-benchmarks#1

Summary by CodeRabbit

  • Bug Fixes

    • Improved variable assignment logic to correctly handle variable value preparation based on write mode, ensuring proper value handling when overwriting conversation variables.
  • Tests

    • Added test coverage for streaming conversation variables with overwrite mode to validate correct variable assignment and output behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 29, 2026

Walkthrough

This 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

Cohort / File(s) Summary
Variable Assigner Core Logic
api/core/workflow/nodes/variable_assigner/v1/node.py
Added blocks_variable_output() method to check if node blocks output for given variable selectors. Modified _run to conditionally use updated_variable.to_object() when write_mode is CLEAR, otherwise income_value.to_object(). Added Set and Tuple type imports.
Test Fixture & Test Case
api/tests/fixtures/workflow/test_streaming_conversation_variables_v1_overwrite.yml, api/tests/unit_tests/core/workflow/graph_engine/test_streaming_conversation_variables.py
New workflow fixture configuring a conversation variable with overwrite mode variable assignment. New test function validating that streaming events correctly emit the overwritten variable value through the workflow pipeline.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A variable's path twists and turns,
Where overwrite mode sets and burns,
The old value fades, new input reigns,
Through workflow nodes and streaming lanes,
Our logic blocks what shouldn't pass—
Hooray for clearer variable class! 🎉

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description only contains a benchmark reference with no substantive information about changes, objectives, or issue resolution as required by the template. Provide a detailed summary of the changes, link the associated issue using 'Fixes #', explain the motivation and context, and complete the relevant checklist items in the template.
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 clearly and specifically describes the main change: deferring streaming responses until referenced variables are updated, which aligns with the addition of the blocks_variable_output method and the conditional logic in _run.

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

✨ Finishing touches
  • 📝 Generate docstrings

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

Copy link

@coderabbitai coderabbitai bot left a comment

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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between f82e17c and a6584b6.

📒 Files selected for processing (3)
  • api/core/workflow/nodes/variable_assigner/v1/node.py
  • api/tests/fixtures/workflow/test_streaming_conversation_variables_v1_overwrite.yml
  • api/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.

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

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

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.

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.

2 participants