T02 · Agent Memory Poisoning
- Location
src/core/gene-processor.js:19- Finding
Persistent memory content can be elevated to system-message authority
- Content
View full analysis
`[${m.role}]: ${m.content}`).join('\n'); const prompt = ` 你是一位资深软件架构师,负责将具体的调试经验“基因化(GeneDistillation)”。 请分析以下对话中的问题解决过程: ${rawText} --- 提炼任务要求: 1. **去变量化**:剔除具体的项目路径、服务器IP、用户名、具体的仓库URL(用 , , 代替)。 2. **逻辑抽象**:描述问题的本质原因,而非表现。例如:“NPM权限错误”而非“安装 axios 报错”。 3. **步骤分解**:将方案分解为 diagnosis(诊断)、patch(修复)、config(配置) 或 workaround(临时规避)。 4. **反模式警告**:指出用户容易踩坑的错误尝试(如有)。 请严格按照以下 JSON 格式输出,不要包含任何 Markdown 标记: { "category": "分类标签", "triggerPattern": "触发该场景的通用特征描述", "rootCause": "本质原因的抽象描述", "actionSequence": [ { "step": 1, "type": "diagnosis/patch/config/workaround", "instruction": "明确的指令", "rationale": "为什么要这么做" } ], "verificationCriterion": "验证问题已解决的标准", "antipatternWarning": "可选的警告信息", "tags": ["标签1", "标签2"] } `; const response = await this.llmClient.ask(prompt); // 清理 LLM 可能输出的 Markdown 块 const cleanJson = response.replace(/```json|```/g, '').trim(); const distilled = JSON.parse(cleanJson); // 为“触发特征”生成向量索引 const searchKey = `${distilled.triggerPattern} ${distilled.rootCause}`; const embedding = await this.embed.vectorize(searchKey); return { ...distilled, embedding }; } ``` `src/core/distill-manager.js:34-55`: ```js async _processTask(history, taskId) { try { console.log(`[EvoMap-Distill] Starting task ${taskId}...`); // 1. 提炼并生成向量 (LLM 1次消耗) const distilled = await this.processor.distill(history); const env = EnvChecker.getF ...[truncated 4612 chars]- Remediation
View remediation
