feat: 添加记忆数量检查,避免在保留数不足时进行整理
This commit is contained in:
parent
f8fc0f7d0f
commit
5273a7b335
@ -132,6 +132,18 @@ impl MemoryMaintenanceService {
|
|||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 记忆数量不足最小保留数时,无需整理,直接跳过
|
||||||
|
// 避免浪费 LLM token 并触发无意义的 "保留数不足" 错误
|
||||||
|
if memories.len() < self.maintenance_config.min_memories_to_keep {
|
||||||
|
tracing::info!(
|
||||||
|
scope_key = %scope_key,
|
||||||
|
count = memories.len(),
|
||||||
|
min_required = self.maintenance_config.min_memories_to_keep,
|
||||||
|
"Skipping scope: not enough memories to organize"
|
||||||
|
);
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(Some(build_memory_maintenance_plan(&memories)))
|
Ok(Some(build_memory_maintenance_plan(&memories)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -619,6 +631,9 @@ pub(crate) fn is_recoverable_maintenance_llm_error(error: &str) -> bool {
|
|||||||
|| normalized.contains("stream timeout")
|
|| normalized.contains("stream timeout")
|
||||||
|| normalized.contains("timed out")
|
|| normalized.contains("timed out")
|
||||||
|| normalized.contains("timeout")
|
|| normalized.contains("timeout")
|
||||||
|
// 验证拒绝 — 记忆太少,跳过本次 scope 即可,不应视为作业失败
|
||||||
|
|| error.contains("保留数不足")
|
||||||
|
|| error.contains("合并比例超限")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_recoverable_maintenance_scope_error(error: &AgentError) -> bool {
|
fn is_recoverable_maintenance_scope_error(error: &AgentError) -> bool {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user