From 57a8c453b913215356a1d3cee3cbdf48a8780927 Mon Sep 17 00:00:00 2001 From: zhsama Date: Tue, 20 Jan 2026 16:45:20 +0800 Subject: [PATCH] fix: Fix variable insertion to only trigger on current line --- .../tool/components/mixed-variable-text-input/index.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/web/app/components/workflow/nodes/tool/components/mixed-variable-text-input/index.tsx b/web/app/components/workflow/nodes/tool/components/mixed-variable-text-input/index.tsx index a0dbcd1070..cebe4dd18c 100644 --- a/web/app/components/workflow/nodes/tool/components/mixed-variable-text-input/index.tsx +++ b/web/app/components/workflow/nodes/tool/components/mixed-variable-text-input/index.tsx @@ -500,8 +500,13 @@ const MixedVariableTextInput = ({ if (!onChange) return - // compute words after the latest '@' and delete them - const valueWithoutTrigger = value.replace(/@[^@\n]*$/, '') + const valueWithoutTrigger = (() => { + const lineStart = value.lastIndexOf('\n') + 1 + const triggerIndex = value.lastIndexOf('@') + if (triggerIndex < lineStart) + return value + return value.slice(0, triggerIndex) + })() const newValue = `{{@${agent.id}.context@}}${valueWithoutTrigger}` if (toolNodeId && paramKey) {