From db57155b30a764324668b00721a9d2cbe072a367 Mon Sep 17 00:00:00 2001 From: Lynn Date: Fri, 20 Mar 2026 23:39:34 +0800 Subject: [PATCH] Fix: get user_id from variables (#13716) ### What problem does this PR solve? Get user_id from canvas variable when input a {} pattern value. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- agent/component/message.py | 9 ++++++++- agent/tools/retrieval.py | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/agent/component/message.py b/agent/component/message.py index fce572c8b0..7f9a9d328c 100644 --- a/agent/component/message.py +++ b/agent/component/message.py @@ -432,8 +432,15 @@ class Message(ComponentBase): if not hasattr(self._param, "memory_ids") or not self._param.memory_ids: return True, "No memory selected." + user_id = self._param.user_id if hasattr(self._param, "user_id") else "" + if user_id: + import re + # is variable + if re.match(r"^{.*}$", user_id): + user_id = self._canvas.get_variable_value(user_id) + message_dict = { - "user_id": self._param.user_id if hasattr(self._param, "user_id") else "", + "user_id": user_id, "agent_id": self._canvas._id, "session_id": self._canvas.task_id, "user_input": self._canvas.get_sys_query(), diff --git a/agent/tools/retrieval.py b/agent/tools/retrieval.py index 6fde0a2cc8..a09a1df37c 100644 --- a/agent/tools/retrieval.py +++ b/agent/tools/retrieval.py @@ -273,6 +273,10 @@ class Retrieval(ToolBase, ABC): # query message filter_dict: dict = {"memory_id": memory_ids} if user_id: + import re + # is variable + if re.match(r"^{.*}$", user_id): + user_id = self._canvas.get_variable_value(user_id) filter_dict["user_id"] = user_id message_list = memory_message_service.query_message(filter_dict, { "query": query,