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

@@ -0,0 +1,41 @@
import { describe, expect, it } from "vitest";
import type { ClawdbotConfig } from "../../config/config.js";
import type { TemplateContext } from "../templating.js";
import { buildThreadingToolContext } from "./agent-runner-utils.js";
describe("buildThreadingToolContext", () => {
const cfg = {} as ClawdbotConfig;
it("uses conversation id for WhatsApp", () => {
const sessionCtx = {
Provider: "whatsapp",
From: "123@g.us",
To: "+15550001",
} as TemplateContext;
const result = buildThreadingToolContext({
sessionCtx,
config: cfg,
hasRepliedRef: undefined,
});
expect(result.currentChannelId).toBe("123@g.us");
});
it("uses the recipient id for other channels", () => {
const sessionCtx = {
Provider: "telegram",
From: "user:42",
To: "chat:99",
} as TemplateContext;
const result = buildThreadingToolContext({
sessionCtx,
config: cfg,
hasRepliedRef: undefined,
});
expect(result.currentChannelId).toBe("chat:99");
});
});