收紧 SuperAgent 的 memory 写入边界#65
Merged
sparkleMing merged 1 commit intoMay 13, 2026
Merged
Conversation
7fc4b6c to
072baad
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
修复 #64。普通 Chat / SuperAgent 在处理“查询历史、总结历史、列 ideas/todos”等任务时,虽然用户没有表达写入 memory 的意图,但模型仍可能因为读写版 memory prompt 的“后台观察”指令和写工具暴露,调用
append_memories写入长期记忆。方案判断
这次把 memory prompt 按 Agent 职责分层,而不是直接收紧共享 prompt,避免影响面过大:
append_memories,不注入写 memory prompt。buildMemoryPrompt(),不挂写工具。改动
buildMemoryReadOnlyPrompt(),用于 Quick Query / 只读模式。buildSuperAgentMemoryManagementPrompt(),在原共享读写 prompt 之上追加 SuperAgent 专属保守边界。quickQuery选择只读 prompt 或 SuperAgent 专属读写 prompt。buildMemoryManagementPrompt()行为,避免改变 CommentAgent、CompanionAgent、KnowledgeInsightAgent 等链路。验证
flutter pub getdart analyze lib/agent/memory/memory_management.dart lib/agent/super_agent/super_agent.dart说明
这次没有改成写入前用户确认,也没有增加审计日志;目标是保持现有自动 memory 能力,但让 SuperAgent 的只读入口和查询型任务边界更清楚。