Skip to content

收紧 SuperAgent 的 memory 写入边界#65

Merged
sparkleMing merged 1 commit into
memex-lab:mainfrom
utopiafar:codex/tighten-memory-prompt
May 13, 2026
Merged

收紧 SuperAgent 的 memory 写入边界#65
sparkleMing merged 1 commit into
memex-lab:mainfrom
utopiafar:codex/tighten-memory-prompt

Conversation

@utopiafar
Copy link
Copy Markdown
Collaborator

@utopiafar utopiafar commented May 12, 2026

背景

修复 #64。普通 Chat / SuperAgent 在处理“查询历史、总结历史、列 ideas/todos”等任务时,虽然用户没有表达写入 memory 的意图,但模型仍可能因为读写版 memory prompt 的“后台观察”指令和写工具暴露,调用 append_memories 写入长期记忆。

方案判断

这次把 memory prompt 按 Agent 职责分层,而不是直接收紧共享 prompt,避免影响面过大:

Agent 适合的 memory 策略
SuperAgent - Quick Query 只读 memory context;不挂 append_memories,不注入写 memory prompt。
SuperAgent - 普通 Chat 使用 SuperAgent 专属保守读写 prompt;允许写当前对话中新产生/明确确认的长期信息,但不把历史检索结果当成新 memory。
MemoryAgent 保持专用 Strict Memory Curator prompt,不受本次改动影响。
ClarificationResolutionAgent 保持专用 clarification resolution prompt,不受本次改动影响。
PkmAgent / CardAgent 继续只读 buildMemoryPrompt(),不挂写工具。
CommentAgent / CompanionAgent / KnowledgeInsightAgent 继续使用原共享读写 prompt;不套 SuperAgent 的历史查询边界,避免误伤角色对话、评论和洞察链路。

改动

  • 新增 buildMemoryReadOnlyPrompt(),用于 Quick Query / 只读模式。
  • 新增 buildSuperAgentMemoryManagementPrompt(),在原共享读写 prompt 之上追加 SuperAgent 专属保守边界。
  • SuperAgent 根据 quickQuery 选择只读 prompt 或 SuperAgent 专属读写 prompt。
  • 保留原 buildMemoryManagementPrompt() 行为,避免改变 CommentAgent、CompanionAgent、KnowledgeInsightAgent 等链路。

验证

  • flutter pub get
  • dart analyze lib/agent/memory/memory_management.dart lib/agent/super_agent/super_agent.dart

说明

这次没有改成写入前用户确认,也没有增加审计日志;目标是保持现有自动 memory 能力,但让 SuperAgent 的只读入口和查询型任务边界更清楚。

@utopiafar utopiafar force-pushed the codex/tighten-memory-prompt branch from 7fc4b6c to 072baad Compare May 12, 2026 07:47
@utopiafar utopiafar requested a review from tigerlaibao May 12, 2026 07:56
@utopiafar utopiafar marked this pull request as ready for review May 12, 2026 07:56
@sparkleMing sparkleMing merged commit a61c323 into memex-lab:main May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants