feat(slack): isolate session context per thread
Each Slack thread now gets its own conversation session instead of sharing one session per channel. DM sessions are unchanged. Added as a generic feature to also support if Feishu threads support is added in the future.
This commit is contained in:
@@ -111,13 +111,15 @@ class BaseChannel(ABC):
|
||||
)
|
||||
return
|
||||
|
||||
meta = metadata or {}
|
||||
msg = InboundMessage(
|
||||
channel=self.name,
|
||||
sender_id=str(sender_id),
|
||||
chat_id=str(chat_id),
|
||||
content=content,
|
||||
media=media or [],
|
||||
metadata=metadata or {}
|
||||
metadata=meta,
|
||||
session_key_override=meta.get("session_key"),
|
||||
)
|
||||
|
||||
await self.bus.publish_inbound(msg)
|
||||
|
||||
@@ -179,6 +179,9 @@ class SlackChannel(BaseChannel):
|
||||
except Exception as e:
|
||||
logger.debug("Slack reactions_add failed: {}", e)
|
||||
|
||||
# Thread-scoped session key for channel/group messages
|
||||
session_key = f"slack:{chat_id}:{thread_ts}" if thread_ts and channel_type != "im" else None
|
||||
|
||||
try:
|
||||
await self._handle_message(
|
||||
sender_id=sender_id,
|
||||
@@ -189,7 +192,8 @@ class SlackChannel(BaseChannel):
|
||||
"event": event,
|
||||
"thread_ts": thread_ts,
|
||||
"channel_type": channel_type,
|
||||
}
|
||||
},
|
||||
"session_key": session_key,
|
||||
},
|
||||
)
|
||||
except Exception:
|
||||
|
||||
Reference in New Issue
Block a user