修复记忆读写流程中的多个缺陷#72
Open
iCanDoAllThingszz wants to merge 1 commit intoBAI-LAB:mainfrom
Open
Conversation
- 修复空QA批次导致跨批次连续性引用过期的问题 (updater.py) - 清理search_sessions中永久为空的关键词相似度死代码 (mid_term.py) - 修复热度触发仅处理单个session的问题,改为循环处理所有达到阈值的session (memoryos.py) - 修复热session无未分析页面时持续占据堆顶不释放的问题 (memoryos.py) - 合并多次save()调用为循环结束后单次保存,减少冗余I/O (memoryos.py) - 修正System Prompt中将conversation metadata误标为User's profile的命名混淆 (prompts.py) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
search_sessions中永久为空的关键词相似度死代码,简化检索评分save()调用为循环结束后单次保存,减少冗余 I/ODetails
1. 连续性引用过期 (
updater.py)process_short_term_to_mid_term中,当所有 evicted QAs 因内容为空被过滤后,方法 early return 但没有更新last_evicted_page_for_continuity。下一次批量驱逐时可能将新页面错误链接到很久以前的过期页面。修复:在 early return 前将引用重置为
None。2. 检索死代码 (
mid_term.py)search_sessions中query_keywords = set()被写死为空集合,导致关键词 Jaccard 相似度计算永远返回 0,keyword_alpha和recency_tau_search参数完全无效。
修复:移除死代码和未使用参数,会话相关性直接使用语义相似度(归一化 embedding 内积 = 余弦相似度)。
3. 单 session 热度处理 (
memoryos.py)_trigger_profile_and_knowledge_update_if_needed使用if只检查堆顶 session,多个 session 同时超过热度阈值时其余被忽略。修复:改为
while循环,逐个处理所有达到阈值的 session,直到堆顶低于阈值。4. 热 session 堆顶阻塞 (
memoryos.py)当热 session 所有页面已分析(
analyzed=True)时,不重置热度,导致每次add_memory都 peek 到同一个 session 又跳过,浪费堆顶且阻塞其他 session。修复:无未分析页面时重置
N_visit和H_segment,释放堆顶给其他 session。5. Prompt 命名混淆 (
prompts.py)System prompt 中
{meta_data_text}被标注为 "User's profile",但实际传入的是user_conversation_meta_data(对话元数据),真正的用户画像在 User prompt的
background_context中。修复:标签从 "User's profile" 更正为 "Current conversation metadata"。
Files Changed
updater.pymid_term.pymemoryos.pyprompts.pyTest plan
🤖 Generated with Claude Code