Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix: conversation var unexpected reset after HITL node (#32936)
非法操作7ffa6c184940
diff --git a/api/dify_graph/runtime/variable_pool.py b/api/dify_graph/runtime/variable_pool.pyindex a2b1af99bb0..e3ef6a2897c 100644--- a/api/dify_graph/runtime/variable_pool.py+++ b/api/dify_graph/runtime/variable_pool.py@@ -65,9 +65,15 @@ class VariablePool(BaseModel):# Add environment variables to the variable poolfor var in self.environment_variables:self.add((ENVIRONMENT_VARIABLE_NODE_ID, var.name), var)- # Add conversation variables to the variable pool+ # Add conversation variables to the variable pool. When restoring from a serialized+ # snapshot, `variable_dictionary` already carries the latest runtime values.+ # In that case, keep existing entries instead of overwriting them with the+ # bootstrap list.for var in self.conversation_variables:- self.add((CONVERSATION_VARIABLE_NODE_ID, var.name), var)+ selector = (CONVERSATION_VARIABLE_NODE_ID, var.name)+ if self._has(selector):+ continue+ self.add(selector, var)# Add rag pipeline variables to the variable poolif self.rag_pipeline_variables:rag_pipeline_variables_map: defaultdict[Any, dict[Any, Any]] = defaultdict(dict)diff --git a/api/tests/unit_tests/core/workflow/entities/test_graph_runtime_state.py b/api/tests/unit_tests/core/workflow/entities/test_graph_runtime_state.pyindex 0df4927697a..22792eb5b3a 100644--- a/api/tests/unit_tests/core/workflow/entities/test_graph_runtime_state.py+++ b/api/tests/unit_tests/core/workflow/entities/test_graph_runtime_state.py@@ -4,8 +4,10 @@ from unittest.mock import MagicMock, patchimport pytest+from dify_graph.constants import CONVERSATION_VARIABLE_NODE_IDfrom dify_graph.model_runtime.entities.llm_entities import LLMUsagefrom dify_graph.runtime import GraphRuntimeState, ReadOnlyGraphRuntimeStateWrapper, VariablePool+from dify_graph.variables.variables import StringVariableclass StubCoordinator:@@ -278,3 +280,17 @@ class TestGraphRuntimeState:assert restored_execution.started is Trueassert new_stub.state == "configured"++ def test_snapshot_restore_preserves_updated_conversation_variable(self):+ variable_pool = VariablePool(+ conversation_variables=[StringVariable(name="session_name", value="before")],+ )+ variable_pool.add((CONVERSATION_VARIABLE_NODE_ID, "session_name"), "after")++ state = GraphRuntimeState(variable_pool=variable_pool, start_at=time())+ snapshot = state.dumps()+ restored = GraphRuntimeState.from_snapshot(snapshot)++ restored_value = restored.variable_pool.get((CONVERSATION_VARIABLE_NODE_ID, "session_name"))+ assert restored_value is not None+ assert restored_value.value == "after"