Files
group_xinghuo_jinrong/docs/memory/2026-09-14.md
T
zhanghongyu_0626 01db9af32b fix(memory): Resolve multi-turn dialogue defects and address existing test bugs
- Fixed three key defects in multi-turn dialogue handling: improved RAG to utilize merged messages, enhanced intent classification with recent memory, and ensured proper merging of chat and consultation memories.
- Closed five existing test bugs unrelated to the current round, including parameter adjustments and assertion corrections in various test files.
- Finalized adjustments in the F-β selection process to align race condition handling in test cases, ensuring all relevant tests pass successfully.

This update enhances the coherence of multi-turn dialogues and improves the reliability of the testing framework.
2026-09-14 00:59:25 +08:00

53 lines
3.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 2026-09-14 · 多轮对话三缺陷修复 + 既存测试 bug 收口 + F-β 选A
> 起因:用户「看看其他 agent 里的构造有没有类似缺陷」。结论:三缺陷是**节点函数设计选择**,
> 非 LangGraph 架构问题;全仓唯一历史感知路径是交易续轮(`_trade_context_window` / `_resolve_advisor_tool`)。
## 做了什么
| 项 | 职责 | 改动要点 |
| --- | --- | --- |
| 缺陷① RAG 只用当前消息 | `visitor_service` / `customer_service` | 各加 `_merged_items` / `_merged_memory_text` / `_rag_query`,从已加载 state 合并 consult+chitchat(按 ts 排序),不再回 Redis 重取 |
| 缺陷② 意图分类只用当前消息 | `customer_prompts` 等 | INTENT prompt 注入 `{memory}`(合并后的近期记忆) |
| 缺陷③ 闲聊+咨询记忆割裂从不合并 | 同上 + `tool_service` / `kb_tools` | RAG query 拼接近期原文(解「那申购呢」省略指代)· `run_tool` 给 `search_knowledge` 转发 `context_window`(原死管道:tool_node 注入但 run_tool 丢弃)· `search_knowledge` 加 `context_window` 参数拼接进 query |
| 既存测试 bug 收口(5 处) | `tests/` + `trade_action_service.py` | 均非本轮三缺陷引入,git stash 取证为 pristine HEAD 即失败(见下) |
| F-β 选A 收口 | `tests/test_convert_accept.py` | 竞态用例抢占者份额 100→50 对齐 L1 四元组 |
**问数线 `analyst_agent` 排除**:单发 NL→SQL,无 RAG/意图/记忆,不适用本修法。
## 5 处既存测试 bug(非本轮引入 · 已取证)
| # | 文件 | 问题 | 修法 |
|---|---|---|---|
| 1 | `tests/test_wave3_customer_service.py` | `fake_suit` 缺 `user_message` 形参 | 补形参 |
| 2 | `tests/test_kb_tools.py` | `test_query_injected` 断言缺 `_context_window` | 断言补 `"_context_window": ""` |
| 3 | `tests/test_wave2_prompts.py` | `VALID_INTENTS` 断言 13,实际 14(含 `trade_action`) | 13→14 |
| 4 | `app/service/trade_action_service.py` | **真 bug**:`looks_like_trade_execute` 把「我上个月申购了啥」误判 trade_action | `_TRADE_QUERY_MARKERS` 补过去问法(`了啥`/`过啥`/`了什么`/`过什么`/`了哪些`/`过哪些`) |
| 5 | `tests/test_chat.py` | `test_chat` mock 返 4 元组,现 `run_customer_chat` 返 5(+`pending_trade`) | 补 `None` |
## F-β 选A 收口
`test_convert_confirm.py` 的 28 条其实已在 `f856ab4`(客户 C3→C4)修掉;仅剩
`test_convert_accept.py::test_accept_uk_idem_race_falls_back_to_idempotent` 1 条:
L1 同键异体→409 后,竞态用例「抢占者」份额 100≠50 四元组不匹配误走冲突 → 抢占者份额改 50。
## 验证
```text
pytest tests/test_trade_gateway.py tests/test_trade_flow_service.py \
tests/test_trade_action_service.py tests/test_convert_accept.py \
tests/test_convert_confirm.py -q # 99 passed / 0 failed
```
## 仍开放
- **git**:`merger` 工作区大量未 commit(本轮三缺陷修复 + 测试 bug 收口 + F-β 收口,由用户确认提交)。
- `docs/memory/MEMORY.md` §0 已落账本轮;`docs/memory/TODO.md` §进行中 已勾选;`docs/memory/ITERATION.md` 已补 09-13/09-14 行。
## 记忆同步
- `MEMORY.md` §0 交接清单(多轮三缺陷 + 5 测试 bug + F-β)
- `TODO.md` §进行中
- `ITERATION.md` 表(09-13 补录 + 09-14 三行)
- 本日志