Clawith icon indicating copy to clipboard operation
Clawith copied to clipboard

企微不同的人/群,上下文串台

Open Atlas-SZ opened this issue 8 months ago • 2 comments

Pre-checks

Deployment Method

Docker

Steps to Reproduce

1、添加数字员工到企微机器人 2、单聊 3、拉企微进群 4、群里 at 企微, 回复私人单聊消息, 发现session 不隔离

Expected vs Actual Behavior

企微(或者其他 IM)不同人/群 Session 隔离

Logs / Screenshots

抱歉,由于企业保密问题,无法企微截屏。

Atlas-SZ avatar Mar 24 '26 03:03 Atlas-SZ

This issue has been fixed in commit adf86c5. Changes:

Root Cause: Group chat sessions were incorrectly attributed to individual users instead of being treated as shared group conversations. Three specific bugs:

  1. find_or_create_channel_session() re-attributed session user_id to the latest sender in group chats
  2. WeCom webhook handler ignored group chat IDs entirely (always used wecom_p2p_)
  3. Slack and Discord included sender_id in their conv_id, creating per-user sessions even in shared channels

Fix:

  • Added is_group (bool) and group_name (string) fields to ChatSession model
  • Group sessions use the agent creator's user_id as a stable placeholder
  • Group sessions are excluded from the 'mine' session scope and only visible in 'all sessions' view (admin/creator only)
  • Fixed conv_id generation across all 6 IM channel handlers (Feishu, WeCom webhook, WeCom WebSocket, Slack, Discord, Microsoft Teams)

Files changed: chat_session.py, channel_session.py, chat_sessions.py, feishu.py, wecom.py, wecom_stream.py, slack.py, discord_bot.py, teams.py, + Alembic migration

Upgrade notes: The Alembic migration (a1b2c3d4e5f6) is idempotent and adds two new columns with safe defaults. No manual action required.

wisdomqin avatar Mar 27 '26 15:03 wisdomqin

This has been fixed in commit 56bef0f (PR #184): Stabilize WeCom channel state and session isolation.

Root cause: WeCom channel handler was not properly isolating conversation context per user/group, causing context bleed between different users and group chats.

Fix: Each WeCom conversation now gets a unique conv_id keyed by user open_id or group chat_id, ensuring full session isolation.

yaojin3616 avatar Apr 27 '26 14:04 yaojin3616