fix(whatsapp): use conversation id for context isolation (#911)

Thanks @tristanmanchester.

Co-authored-by: Tristan Manchester <tmanchester96@gmail.com>
This commit is contained in:
Peter Steinberger
2026-01-14 20:05:29 +00:00
parent 0235eb6c72
commit e65e5f40c9
3 changed files with 45 additions and 1 deletions

View File

@@ -25,13 +25,15 @@ export function buildThreadingToolContext(params: {
if (!provider) return {};
const dock = getChannelDock(provider);
if (!dock?.threading?.buildToolContext) return {};
// WhatsApp context isolation keys off conversation id, not the bot's own number.
const threadingTo = provider === "whatsapp" ? sessionCtx.From ?? sessionCtx.To : sessionCtx.To;
return (
dock.threading.buildToolContext({
cfg: config,
accountId: sessionCtx.AccountId,
context: {
Channel: sessionCtx.Provider,
To: sessionCtx.To,
To: threadingTo,
ReplyToId: sessionCtx.ReplyToId,
ThreadLabel: sessionCtx.ThreadLabel,
},