From dc8c018e28b3e97b043a267cd6e2a5ac8b018331 Mon Sep 17 00:00:00 2001 From: zhsama Date: Tue, 20 Jan 2026 16:48:05 +0800 Subject: [PATCH] refactor: Refactor agent context insertion to use regex --- .../tool/components/mixed-variable-text-input/index.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 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 cebe4dd18c..a0dbcd1070 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,13 +500,8 @@ const MixedVariableTextInput = ({ if (!onChange) return - const valueWithoutTrigger = (() => { - const lineStart = value.lastIndexOf('\n') + 1 - const triggerIndex = value.lastIndexOf('@') - if (triggerIndex < lineStart) - return value - return value.slice(0, triggerIndex) - })() + // compute words after the latest '@' and delete them + const valueWithoutTrigger = value.replace(/@[^@\n]*$/, '') const newValue = `{{@${agent.id}.context@}}${valueWithoutTrigger}` if (toolNodeId && paramKey) {