From bbb640c9a2fcecb9d3fc31af616957cfb4c7c26e Mon Sep 17 00:00:00 2001 From: Stream Date: Wed, 20 Aug 2025 19:45:18 +0800 Subject: [PATCH] feat: add MemoryBlock to VariablePool --- api/core/workflow/entities/variable_pool.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/core/workflow/entities/variable_pool.py b/api/core/workflow/entities/variable_pool.py index fb0794844e..67f5551dea 100644 --- a/api/core/workflow/entities/variable_pool.py +++ b/api/core/workflow/entities/variable_pool.py @@ -46,6 +46,10 @@ class VariablePool(BaseModel): description="Conversation variables.", default_factory=list, ) + memory_blocks: Mapping[str, str] = Field( + description="Memory blocks.", + default_factory=dict, + ) def model_post_init(self, context: Any, /) -> None: # Create a mapping from field names to SystemVariableKey enum values @@ -56,6 +60,9 @@ class VariablePool(BaseModel): # Add conversation variables to the variable pool for var in self.conversation_variables: self.add((CONVERSATION_VARIABLE_NODE_ID, var.name), var) + # Add memory blocks to the variable pool + for memory_id, memory_value in self.memory_blocks.items(): + self.add(['memory_block', memory_id], memory_value) def add(self, selector: Sequence[str], value: Any, /) -> None: """