[错误] Pi 配置文件在嵌套 XML 块内分割部分 - 内存块被注入两次
作者: muzimu217创建于 2026年9月17日更新于 2026年9月18日
MemoryProxy/src/injection/agents/pi/profile.ts:
const LABEL_RE = /^([A-Z][A-Za-z ]*):\s*$/;
const XML_OPEN_RE = /^<([a-z_]+)>\s*$/;
for (const line of lines) {
const labelMatch = LABEL_RE.exec(line); // no nesting check
const xmlMatch = XML_OPEN_RE.exec(line); // no nesting check
if (labelMatch || xmlMatch) {
flush();
currentKey = labelMatch ? labelMatch[1].trim() : xmlMatch![1];
currentKind = "markdown_section";
}
buffer.push(line);
}The real Pi prompt shape (see the fixture that shipped with #1126):
<project_context>
Project-specific instructions and guidelines:内容来源: TencentCloud/TencentDB-Agent-Memory