mirror of
https://github.com/Tencent/WeKnora.git
synced 2026-06-04 13:30:32 +08:00
Three bugs fixed: 1. Session cross-contamination (#1066): resolveUserSession and resolveThreadSession looked up ChannelSession by (platform, user_id, chat_id, tenant_id) without agent_id. When the same user talked to two bots bound to different agents under the same tenant, they shared a session — mixing knowledge base context. Add agent_id to all four WHERE clauses and update the DB unique indexes to match. 2. Swapped parameters in resolveThreadSession: the SQL expected (chat_id, thread_id) but Go args passed (threadID, msg.ChatID). 3. Orphaned ChannelSession crash (#1046): deleting a session from the WeKnora UI soft-deletes it (GORM), but the ChannelSession row survives because soft-delete doesn't trigger SQL ON DELETE CASCADE. Subsequent IM messages hit "record not found" on GetSession and the bot becomes permanently unresponsive. Now detect this case, recycle the stale mapping, and transparently create a fresh session.