fix(api): defer streaming response until referenced variables are updated#86
Conversation
Greptile SummaryThis PR fixes a streaming bug where conversation variables were output before being updated by the Variable Assigner node. The fix adds a
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant WorkflowEngine
participant ResponseCoordinator
participant VariableAssignerNode
participant VariablePool
participant AnswerNode
User->>WorkflowEngine: Start workflow with query
WorkflowEngine->>ResponseCoordinator: Initialize with conversation variables
ResponseCoordinator->>ResponseCoordinator: Build paths to response nodes
ResponseCoordinator->>VariableAssignerNode: Check blocks_variable_output(conv_var)
VariableAssignerNode-->>ResponseCoordinator: Returns True (blocks streaming)
WorkflowEngine->>VariableAssignerNode: Execute node
VariableAssignerNode->>VariablePool: Get original conversation variable
VariableAssignerNode->>VariablePool: Get input value (sys.query)
VariableAssignerNode->>VariableAssignerNode: Create updated variable
VariableAssignerNode->>VariablePool: Update conversation variable
VariableAssignerNode->>WorkflowEngine: Emit NodeRunStreamChunkEvent
VariableAssignerNode-->>WorkflowEngine: Return NodeRunResult
WorkflowEngine->>ResponseCoordinator: Node completed
ResponseCoordinator->>ResponseCoordinator: Remove blocking edge
ResponseCoordinator->>AnswerNode: Start streaming with updated conv_var
AnswerNode->>VariablePool: Reference updated conv_var
AnswerNode->>User: Stream response with correct value
|
| @@ -1,5 +1,5 @@ | |||
| from collections.abc import Mapping, Sequence | |||
| from typing import TYPE_CHECKING, Any | |||
| from typing import TYPE_CHECKING, Any, Set, Tuple | |||
There was a problem hiding this comment.
style: uses legacy typing imports Set and Tuple instead of modern Python 3.12+ syntax
| from typing import TYPE_CHECKING, Any, Set, Tuple | |
| from typing import TYPE_CHECKING, Any |
Then update line 36 to use set[tuple[str, ...]] instead of Set[Tuple[str, ...]]
Context Used: Context from dashboard - CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: api/core/workflow/nodes/variable_assigner/v1/node.py
Line: 2:2
Comment:
**style:** uses legacy typing imports `Set` and `Tuple` instead of modern Python 3.12+ syntax
```suggestion
from typing import TYPE_CHECKING, Any
```
Then update line 36 to use `set[tuple[str, ...]]` instead of `Set[Tuple[str, ...]]`
**Context Used:** Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=a5f96311-5bd1-49f2-9828-2ee0c089c012))
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.
Benchmark PR from qodo-benchmark#423