Skip to content

fix(channels): 群聊止血——企微 is_group 以 chattype 为准,群记忆红线(不写不读) - #52

Open
tianling536 wants to merge 1 commit into
OpenBMB:mainfrom
tianling536:feat/group-chat-redline
Open

fix(channels): 群聊止血——企微 is_group 以 chattype 为准,群记忆红线(不写不读)#52
tianling536 wants to merge 1 commit into
OpenBMB:mainfrom
tianling536:feat/group-chat-redline

Conversation

@tianling536

Copy link
Copy Markdown
Contributor

概述

「群聊 + 多数字员工沟通 + 分工」系列的第 1 个 PR(止血包),先拆掉两个上线即炸的雷,后续 PR(成员级群聊/转派/分工编排)以此为基。

问题

  1. 企微群消息误归类(wecom.py):chattype=group 但缺 chatid 的异常帧被静默降级为私聊,真实群消息混入该成员的 p2p 会话(回复还会私聊发出);is_group 仅看 chatid 存在性,chattype=single 却带 chatid 的帧会被误判为群。
  2. 群记忆混忆(隐私级):群聊会话把所有成员映射到同一个"群账号",后台记忆任务照常沉淀、检索照常命中——张三在群里说的偏好可能被回给李四。

修复

  • 企微 is_groupchattype 为准:缺 chatid 的群帧记 warning 后丢弃(无法构成稳定群会话,绝不降级混入私聊);singlechatid 按私聊处理(session_id/group_id/context_token 同步按 is_group 归位)。
  • 群记忆红线(不写不读):
    • 写:memory/jobs.py 后台任务拿到会话后,群会话直接跳过(零 LLM 开销,单一入口覆盖全部触发路径);
    • 读:agent_loop.py 两处 context_memories 调用点,群会话跳过检索——成员私人偏好绝不会在群里被念出来;
    • 私聊行为完全不变。
  • 新增 is_group_conv_id(channel, conv_id):兼容无 scope(wechat_group_x)、带 scope(wecom_{corp}_group_x)、成员级(...#member,为后续 PR 预留)三种格式;并顺带修复会话列表接口漏判带 scope 企微群(is_group 一直为 False)的既有瑕疵。

测试

  • 企微:缺 chatid 群帧→None+warning;single 带 chatid→私聊(新行为固化);
  • is_group_conv_id:三种群格式判真、私聊/跨渠道不误判;
  • 记忆红线:群会话后台任务不调用 capture、无任何写入;私聊会话正常进入 capture(不误伤);
  • 全量 1205 passed、ruff 零告警(唯一失败为 main 预存在的 test_verification_runs_bounded_text_stream_and_json_probes,与本 PR 无关)。

兼容性

  • 无 schema 变更;存量群会话/记忆保留只读,不迁移不删除;
  • 私聊、绑定、自动分发全链路无行为变化。

群聊+多员工+分工系列的第 1 个 PR(止血包):

- 企微 is_group 改以 chattype 为准:chattype=group 缺 chatid 的异常帧
  记 warning 后丢弃,不再降级混入成员私聊会话;single 带 chatid 不再误判为群
- 群记忆红线:群聊会话不写记忆(memory job 直接跳过)、不检索个人记忆
  (agent_loop 两处 context_memories 调用点跳过)——成员私人偏好绝不会
  混入群账号或被念给群里其他人
- 新增 is_group_conv_id(channel, conv_id) 判定(兼容无 scope/带 scope/
  成员级 #member 三种格式),并修复会话列表漏判带 scope 企微群的既有瑕疵

测试:企微缺 chatid 丢弃+single 带 chatid 按私聊、helper 三种格式、
群会话 capture 跳过/私聊不受影响;全量 1205 passed、ruff 零告警
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant