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:
Paul
2026-02-23 10:15:12 +00:00
parent b2a1d1208e
commit 1f7a81e5ee
3 changed files with 10 additions and 3 deletions

View File

@@ -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)

View File

@@ -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: