Repository navigation
fix(memory): align extraction, tool outcomes and bounded recall - #752
openjiuwen-sync-bot[bot] wants to merge 1 commit into
Conversation
|
zhengpeng seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
1 similar comment
|
zhengpeng seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
|
head_sha: 变更摘要本 PR 围绕记忆子系统的一致性做修正:统一记忆工具返回结构为 主要改动
注: 本次仅按要求做变更摘要,未执行任何代码审查或仓库探查。 |
|
head_sha: 代码审查审查结论
💬 仅评论 |
| caplog.set_level( | ||
| logging.INFO, | ||
| logger="agent_memory.construction.extractor_impl.team_llm_extractor", | ||
| ) |
There was a problem hiding this comment.
head_sha: 00a482fa4cbf87df895746d6824fbc08866c2d60
🟡 Medium Priority
变更行(test_team_llm_extractor.py:72-75)用 caplog.set_level(logging.INFO, logger="agent_memory.construction.extractor_impl.team_llm_extractor") 打开日志捕获,但被测符号来自 jiuwen_memory.construction.extractor_impl.team_llm_extractor(第 7 行 import)。同目录既有测试全部按模块真实路径命名:test_extractor.py:574-575 用 get_logger("jiuwen_memory.construction.extractor_impl.llm_extractor")、test_entity_linker.py:613-614 用 logger="jiuwen_memory.construction.index_builder_impl.entity_index_builder"、test_extractor_title.py:149 用 logger=logger.name(即 __name__)。说明这些 construction 模块的 logger 名以 jiuwen_memory. 前缀派生,agent_memory. 前缀的 set_level 只会作用到一个并不存在的同名 logger。失败路径:模块 logger 的有效级别仍为默认 WARNING,logger.info("... raw=%d accepted=%d ...") 在记录时被级别过滤,caplog.text 里没有对应文本,第 78-82 行的 raw=33 accepted=1、'bad_source_id': 31 断言直接失败;即使环境把级别放宽到 INFO,该断言也已退化为「捕获到任意日志」而不再真正校验目标 logger,脱敏断言(80-82 行)同样可能落在空文本上而恒真。修复方向:改为从被测模块导入 logger 并用 logger.name 设置级别(与 test_extractor_title.py 一致),或直接写 jiuwen_memory.construction.extractor_impl.team_llm_extractor。
建议:用模块自身 logger 的名字设置 caplog 级别:from jiuwen_memory.construction.extractor_impl import team_llm_extractor 后 caplog.set_level(logging.INFO, logger=team_llm_extractor.logger.name),避免前缀写错导致断言落空或失败。
| return json.dumps({"error": "Memory write failed", "stored": False}) | ||
| return json.dumps({"stored": bool(result.item_id), "item_id": result.item_id}) | ||
| return json.dumps({"success": False, "error": "Memory write failed"}) | ||
| return json.dumps({"success": True}) |
There was a problem hiding this comment.
head_sha: 00a482fa4cbf87df895746d6824fbc08866c2d60
🟡 Medium Priority
改动行(jiuwen_memory_adapter/jiuwenswarm/team_memory.py:213-215)把 team_memory_write 的返回从 {"stored": bool(result.item_id), "item_id": result.item_id} 改成常量 {"success": True},只要 result is not None 就报成功。
契约 1:同仓库 work_memory.py:367-377 明确写着「add 返回 item_id=None:extractor 产空(LLM 返回不可解析/未产出候选)→ 未持久化任何记忆。不可报成功(false success)」;本改动把这条已经写在同族实现的规则在 team 写入路径上去掉了。
契约 2:tests/unit/jiuwen_memory_adapter/test_agent_memory_provider_unit.py 的 ("empty", "", 0) 用例(HTTP 200 空响应)现在断言 {"success": True},即空抽取也被判成功。
失败模式:infer=True 的抽取在 LLM 返回不可解析/空候选(或去重后无新单元)时,客户端拿到的仍是非 None 结果但 item_id 为 None,工具回 {"success": True};宿主/LLM 会认为「已记住」,而实际没有任何条目落盘——这正是本 PR(#367「记忆工具调用失败无法被感知」)要修的那类不可感知失败,只是方向从「失败不可感知」变成「空写不可感知」。
建议:在 result.item_id 为空时不要无条件返回 success:区分「去重(已有记忆)」与「抽取为空(未落盘)」两种情形,前者可回 success+deduped,后者应回 {"success": False, "error": ...},与 work_memory.py 中 _procedural 已标注的「不可报成功(false success)」口径一致;必要时同步修正 test_agent_memory_provider_unit.py 的 "empty" 用例期望。
Paired: GitHub #752 ↔ GitCode !534
What type of PR is this?
/kind
Self-checklist:(请自检,在[ ]内打上x,我们将检视你的完成情况,否则会导致pr无法合入)
Linked Closing Issues: