fix: dedupe inbound Telegram DM replies per agent (#40519)

Merged via squash.

Prepared head SHA: 6e235e7d1f
Co-authored-by: obviyus <22031114+obviyus@users.noreply.github.com>
Co-authored-by: obviyus <22031114+obviyus@users.noreply.github.com>
Reviewed-by: @obviyus
This commit is contained in:
Ayaan Zaidi
2026-03-09 09:31:05 +05:30
committed by GitHub
parent 8befd88119
commit 26e76f9a61
4 changed files with 79 additions and 4 deletions

View File

@@ -236,7 +236,7 @@ describe("inbound dedupe", () => {
).toBe(false);
});
it("does not dedupe across session keys", () => {
it("does not dedupe across agent ids", () => {
resetInboundDedupe();
const base: MsgContext = {
Provider: "whatsapp",
@@ -248,12 +248,36 @@ describe("inbound dedupe", () => {
shouldSkipDuplicateInbound({ ...base, SessionKey: "agent:alpha:main" }, { now: 100 }),
).toBe(false);
expect(
shouldSkipDuplicateInbound({ ...base, SessionKey: "agent:bravo:main" }, { now: 200 }),
shouldSkipDuplicateInbound(
{ ...base, SessionKey: "agent:bravo:whatsapp:direct:+1555" },
{
now: 200,
},
),
).toBe(false);
expect(
shouldSkipDuplicateInbound({ ...base, SessionKey: "agent:alpha:main" }, { now: 300 }),
).toBe(true);
});
it("dedupes when the same agent sees the same inbound message under different session keys", () => {
resetInboundDedupe();
const base: MsgContext = {
Provider: "telegram",
OriginatingChannel: "telegram",
OriginatingTo: "telegram:7463849194",
MessageSid: "msg-1",
};
expect(
shouldSkipDuplicateInbound({ ...base, SessionKey: "agent:main:main" }, { now: 100 }),
).toBe(false);
expect(
shouldSkipDuplicateInbound(
{ ...base, SessionKey: "agent:main:telegram:direct:7463849194" },
{ now: 200 },
),
).toBe(true);
});
});
describe("createInboundDebouncer", () => {