From e28817b5da04512651554378616db7323e3774c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ACT=E4=B8=B6=E6=B5=81=E6=98=9F=E9=9B=A8?= <1340145680@qq.com> Date: Thu, 2 Apr 2026 02:34:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=8A=E8=AE=B0=E5=BF=86?= =?UTF-8?q?=E6=84=8F=E5=A4=96=E6=90=BA=E5=B8=A6xml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/agents/productionAgent/index.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/agents/productionAgent/index.ts b/src/agents/productionAgent/index.ts index 281b789..885f600 100644 --- a/src/agents/productionAgent/index.ts +++ b/src/agents/productionAgent/index.ts @@ -58,7 +58,7 @@ export async function decisionAI(ctx: AgentContext) { ...createSubAgent(ctx), }, onFinish: async (completion) => { - await memory.add("assistant:decision", completion.text); + await memory.add("assistant:decision", removeAllXmlTags(completion.text)); }, }); @@ -109,7 +109,7 @@ function createSubAgent(parentCtx: AgentContext) { } if (fullResponse.trim()) { - await memory.add(memoryKey, fullResponse, { + await memory.add(memoryKey, removeAllXmlTags(fullResponse), { name, createTime: new Date(subMsg.datetime).getTime(), }); @@ -193,3 +193,11 @@ async function createArtSkills(artName: string) { }; return res; } + + +function removeAllXmlTags(text: string): string { + text = text.replace(/<([a-zA-Z][\w-]*)(\s+[^>]*)?>([\s\S]*?)<\/\1>/g, ""); + text = text.replace(/<([a-zA-Z][\w-]*)(\s+[^>]*)?\/>/g, ""); + text = text.replace(/<\/?[a-zA-Z][\w-]*(\s+[^>]*)?>/g, ""); + return text.trim(); +}