Skip to content

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

Open
tomerqodo wants to merge 3 commits intoqodo_claude_vs_qodo_base_fixapi_defer_streaming_response_until_referenced_variables_are_updated_pr1from
qodo_claude_vs_qodo_head_fixapi_defer_streaming_response_until_referenced_variables_are_updated_pr1
Open

fix(api): defer streaming response until referenced variables are updated#152
tomerqodo wants to merge 3 commits intoqodo_claude_vs_qodo_base_fixapi_defer_streaming_response_until_referenced_variables_are_updated_pr1from
qodo_claude_vs_qodo_head_fixapi_defer_streaming_response_until_referenced_variables_are_updated_pr1

Conversation

@tomerqodo
Copy link

Benchmark PR from agentic-review-benchmarks#1

@qodo-code-review
Copy link

Review Summary by Qodo

Defer streaming response until conversation variables are updated

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Add blocks_variable_output() method to defer streaming until variable assignment
• Fix result input value calculation for CLEAR write mode
• Add test case validating v1 Variable Assigner blocks streaming correctly
• Create fixture for streaming conversation variables v1 overwrite scenario
Diagram
flowchart LR
  A["Variable Assigner Node"] -->|blocks_variable_output| B["Check if node updates requested variables"]
  B -->|True| C["Defer streaming response"]
  C -->|After assignment| D["Stream variable updates"]
  A -->|_run method| E["Calculate result input value"]
  E -->|CLEAR mode| F["Use updated variable value"]
  E -->|Other modes| G["Use income value"]
Loading

Grey Divider

File Changes

1. api/core/workflow/nodes/variable_assigner/v1/node.py 🐞 Bug fix +18/-2

Add variable blocking check and fix CLEAR mode value

• Added blocks_variable_output() method to check if node updates requested conversation variables
• Fixed result input value calculation to use updated_variable for CLEAR write mode instead of
 income_value
• Added imports for Set and Tuple type hints

api/core/workflow/nodes/variable_assigner/v1/node.py


2. api/tests/unit_tests/core/workflow/graph_engine/test_streaming_conversation_variables.py 🧪 Tests +30/-0

Add test for v1 Variable Assigner streaming behavior

• Added new test test_streaming_conversation_variables_v1_overwrite_waits_for_assignment() to
 validate streaming behavior
• Test verifies that conversation variable chunk events are emitted with correct values
• Test ensures streamed variable values match the input query

api/tests/unit_tests/core/workflow/graph_engine/test_streaming_conversation_variables.py


3. api/tests/fixtures/workflow/test_streaming_conversation_variables_v1_overwrite.yml 🧪 Tests +158/-0

Create workflow fixture for streaming variable test

• Created new workflow fixture for testing v1 Variable Assigner with overwrite mode
• Defines conversation variable conv_var with default value
• Includes start node, variable assigner node (overwrite mode), and answer node
• Answer node references the conversation variable to validate streaming output

api/tests/fixtures/workflow/test_streaming_conversation_variables_v1_overwrite.yml


Grey Divider

Qodo Logo

@qodo-code-review
Copy link

qodo-code-review bot commented Mar 10, 2026

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (3) 📎 Requirement gaps (0)

Grey Divider


Action required

1. Set/Tuple annotations used 📘 Rule violation ✓ Correctness
Description
New type annotations use legacy typing.Set/typing.Tuple instead of Python 3.12+ built-in
generics. This violates the modern typing syntax requirement and may trigger lint/type-check rules.
Code

api/core/workflow/nodes/variable_assigner/v1/node.py[36]

+    def blocks_variable_output(self, variable_selectors: Set[Tuple[str, ...]]) -> bool:
Evidence
PR Compliance ID 4 requires modern Python 3.12+ typing syntax; the new method signature uses
Set[Tuple[...]] from typing rather than set[tuple[...]].

AGENTS.md
api/core/workflow/nodes/variable_assigner/v1/node.py[36-36]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
New annotations use legacy `typing.Set`/`typing.Tuple` instead of Python 3.12+ built-in generics.

## Issue Context
The repository requires modern typing syntax (e.g., `set[tuple[str, ...]]`).

## Fix Focus Areas
- api/core/workflow/nodes/variable_assigner/v1/node.py[1-3]
- api/core/workflow/nodes/variable_assigner/v1/node.py[36-43]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Test missing return annotation 📘 Rule violation ✓ Correctness
Description
The newly added pytest function has no return type annotation. This violates the requirement that
all Python functions include parameter and return type annotations.
Code

api/tests/unit_tests/core/workflow/graph_engine/test_streaming_conversation_variables.py[50]

+def test_streaming_conversation_variables_v1_overwrite_waits_for_assignment():
Evidence
PR Compliance ID 1 requires return type annotations on all function definitions; the new test
function is defined without -> None.

AGENTS.md
api/tests/unit_tests/core/workflow/graph_engine/test_streaming_conversation_variables.py[50-50]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new pytest test function is missing a return type annotation.

## Issue Context
The compliance checklist requires type annotations for all function parameters and return values.

## Fix Focus Areas
- api/tests/unit_tests/core/workflow/graph_engine/test_streaming_conversation_variables.py[50-50]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Unhashable selector check 🐞 Bug ✓ Correctness
Description
VariableAssignerNode(v1).blocks_variable_output checks a list-based assigned_variable_selector for
membership in a set of tuple selectors, which raises TypeError (unhashable list) during
ResponseStreamCoordinator path analysis and can break streaming execution.
Code

api/core/workflow/nodes/variable_assigner/v1/node.py[R36-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
Evidence
ResponseStreamCoordinator builds variable_selectors as a set of tuples and calls
blocks_variable_output on upstream nodes; v1 VariableAssignerData uses Sequence[str] and workflow
configs/fixtures provide assigned_variable_selector as a YAML list, so the v1 implementation
attempts list in set[tuple], which is a TypeError at runtime. The v2 implementation demonstrates
the required conversion to tuple before membership testing.

api/core/workflow/nodes/variable_assigner/v1/node.py[36-43]
api/core/workflow/graph_engine/response_coordinator/coordinator.py[171-176]
api/core/workflow/graph_engine/response_coordinator/coordinator.py[215-221]
api/core/workflow/nodes/variable_assigner/v1/node_data.py[13-16]
api/tests/fixtures/workflow/test_streaming_conversation_variables_v1_overwrite.yml[130-134]
api/core/workflow/nodes/variable_assigner/v2/node.py[70-85]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`VariableAssignerNode` v1 implements `blocks_variable_output()` by checking a list selector (`assigned_variable_selector`) for membership in `variable_selectors`, which is a `set[tuple[str, ...]]`. This causes a runtime `TypeError: unhashable type: 'list'` when the response coordinator analyzes paths for streaming.

### Issue Context
`ResponseStreamCoordinator` builds `variable_selectors` as tuples (`tuple(segment.selector[:2])`) and calls `source_node.blocks_variable_output(variable_selectors)` for nodes on paths to response nodes.

### Fix Focus Areas
- api/core/workflow/nodes/variable_assigner/v1/node.py[36-43]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

4. Test lacks AAA structure 📘 Rule violation ⛯ Reliability
Description
The new test mixes setup, execution, and assertions without clearly separated Arrange/Act/Assert
sections. This reduces readability and violates the AAA-pattern requirement for pytest tests.
Code

api/tests/unit_tests/core/workflow/graph_engine/test_streaming_conversation_variables.py[R50-77]

+def test_streaming_conversation_variables_v1_overwrite_waits_for_assignment():
+    fixture_name = "test_streaming_conversation_variables_v1_overwrite"
+    input_query = "overwrite-value"
+
+    case = WorkflowTestCase(
+        fixture_path=fixture_name,
+        use_auto_mock=False,
+        mock_config=MockConfigBuilder().build(),
+        query=input_query,
+        inputs={},
+        expected_outputs={"answer": f"Current Value Of `conv_var` is:{input_query}"},
+    )
+
+    runner = TableTestRunner()
+    result = runner.run_test_case(case)
+    assert result.success, f"Test failed: {result.error}"
+
+    events = result.events
+    conv_var_chunk_events = [
+        event
+        for event in events
+        if isinstance(event, NodeRunStreamChunkEvent) and event.selector == ["conversation", "conv_var"]
+    ]
+
+    assert conv_var_chunk_events, "Expected conversation variable chunk events to be emitted"
+    assert all(event.chunk == input_query for event in conv_var_chunk_events), (
+        "Expected streamed conversation variable value to match the input query"
+    )
Evidence
PR Compliance ID 8 requires clear AAA separation; the new test proceeds through setup, execution,
and multiple assertions without explicit phase delineation.

AGENTS.md
api/tests/unit_tests/core/workflow/graph_engine/test_streaming_conversation_variables.py[50-77]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new pytest test does not clearly separate Arrange, Act, and Assert phases.

## Issue Context
The compliance checklist requires tests to follow the AAA pattern for readability and maintainability.

## Fix Focus Areas
- api/tests/unit_tests/core/workflow/graph_engine/test_streaming_conversation_variables.py[50-77]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

graph_runtime_state=graph_runtime_state,
)

def blocks_variable_output(self, variable_selectors: Set[Tuple[str, ...]]) -> bool:

Choose a reason for hiding this comment

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

Action required

1. set/tuple annotations used 📘 Rule violation ✓ Correctness

New type annotations use legacy typing.Set/typing.Tuple instead of Python 3.12+ built-in
generics. This violates the modern typing syntax requirement and may trigger lint/type-check rules.
Agent Prompt
## Issue description
New annotations use legacy `typing.Set`/`typing.Tuple` instead of Python 3.12+ built-in generics.

## Issue Context
The repository requires modern typing syntax (e.g., `set[tuple[str, ...]]`).

## Fix Focus Areas
- api/core/workflow/nodes/variable_assigner/v1/node.py[1-3]
- api/core/workflow/nodes/variable_assigner/v1/node.py[36-43]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

assert result.success, f"Test failed: {result.error}"


def test_streaming_conversation_variables_v1_overwrite_waits_for_assignment():

Choose a reason for hiding this comment

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

Action required

2. Test missing return annotation 📘 Rule violation ✓ Correctness

The newly added pytest function has no return type annotation. This violates the requirement that
all Python functions include parameter and return type annotations.
Agent Prompt
## Issue description
The new pytest test function is missing a return type annotation.

## Issue Context
The compliance checklist requires type annotations for all function parameters and return values.

## Fix Focus Areas
- api/tests/unit_tests/core/workflow/graph_engine/test_streaming_conversation_variables.py[50-50]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +50 to +77
def test_streaming_conversation_variables_v1_overwrite_waits_for_assignment():
fixture_name = "test_streaming_conversation_variables_v1_overwrite"
input_query = "overwrite-value"

case = WorkflowTestCase(
fixture_path=fixture_name,
use_auto_mock=False,
mock_config=MockConfigBuilder().build(),
query=input_query,
inputs={},
expected_outputs={"answer": f"Current Value Of `conv_var` is:{input_query}"},
)

runner = TableTestRunner()
result = runner.run_test_case(case)
assert result.success, f"Test failed: {result.error}"

events = result.events
conv_var_chunk_events = [
event
for event in events
if isinstance(event, NodeRunStreamChunkEvent) and event.selector == ["conversation", "conv_var"]
]

assert conv_var_chunk_events, "Expected conversation variable chunk events to be emitted"
assert all(event.chunk == input_query for event in conv_var_chunk_events), (
"Expected streamed conversation variable value to match the input query"
)

Choose a reason for hiding this comment

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

Remediation recommended

3. Test lacks aaa structure 📘 Rule violation ⛯ Reliability

The new test mixes setup, execution, and assertions without clearly separated Arrange/Act/Assert
sections. This reduces readability and violates the AAA-pattern requirement for pytest tests.
Agent Prompt
## Issue description
The new pytest test does not clearly separate Arrange, Act, and Assert phases.

## Issue Context
The compliance checklist requires tests to follow the AAA pattern for readability and maintainability.

## Fix Focus Areas
- api/tests/unit_tests/core/workflow/graph_engine/test_streaming_conversation_variables.py[50-77]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

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

Choose a reason for hiding this comment

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

Action required

4. Unhashable selector check 🐞 Bug ✓ Correctness

VariableAssignerNode(v1).blocks_variable_output checks a list-based assigned_variable_selector for
membership in a set of tuple selectors, which raises TypeError (unhashable list) during
ResponseStreamCoordinator path analysis and can break streaming execution.
Agent Prompt
### Issue description
`VariableAssignerNode` v1 implements `blocks_variable_output()` by checking a list selector (`assigned_variable_selector`) for membership in `variable_selectors`, which is a `set[tuple[str, ...]]`. This causes a runtime `TypeError: unhashable type: 'list'` when the response coordinator analyzes paths for streaming.

### Issue Context
`ResponseStreamCoordinator` builds `variable_selectors` as tuples (`tuple(segment.selector[:2])`) and calls `source_node.blocks_variable_output(variable_selectors)` for nodes on paths to response nodes.

### Fix Focus Areas
- api/core/workflow/nodes/variable_assigner/v1/node.py[36-43]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

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