fix: 修复记忆系统自循环与计算层污染

- 删 syncGraphToDocs(): Graph 快照不再写入 Document,避免污染向量索引和三层隔离
- 删 toolCallRing(): 已被工具 NoMemory/Cleaner 机制取代,不再需要独立环形缓冲
- 加 toolOutputClean 回调线程 Prune→ContextToDoc: 归档时按 NoMemory 跳过、Cleaner 清洗后再过 jieba,原文保留
- 加 eval_status 持久化 (RecallPending/UpdateEvalStatus/ResolveEvaluating): 避免重复 LLM 评估
This commit is contained in:
root
2026-07-26 19:29:01 +08:00
parent d1b879d5bd
commit 9fbb3e5790
7 changed files with 373 additions and 280 deletions

View File

@ -105,20 +105,6 @@ type Agent struct {
noMergeMarkers map[string]int
noMergeMu sync.Mutex
// toolCallRing 保护最近 40 条工具调用记录不被上下文淘汰,
// 确保 LLM 不会重复调用同一工具、反复查询同一数据。
toolCallRing []ToolCallRecord
toolCallRingMax int
toolCallRingMu sync.Mutex // 独立的锁,不与 a.mu 混用避免死锁
}
// ToolCallRecord 记录一次工具调用,保留元数据供后续 LLM 回合参考。
type ToolCallRecord struct {
Timestamp time.Time `json:"timestamp"`
Name string `json:"name"`
Args string `json:"args,omitempty"` // 参数摘要(最多 200 字符)
ResultStub string `json:"result_stub"` // 结果摘要(具体内容通过文本记忆层获取)
FullResult string `json:"result_full,omitempty"` // 完整结果(仅保留最近 5 条,其余仅存 stub)
}
type AgentConfig struct {
@ -202,8 +188,7 @@ func New(cfg AgentConfig) *Agent {
thinkingEnabled: cfg.ThinkingEnabled,
inputCfg: cfg.InputProcessing,
noMergeMarkers: make(map[string]int),
toolCallRing: make([]ToolCallRecord, 0, 40),
toolCallRingMax: 40,
}
}