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(); +}