From cae64ee360a84abcc2ce2fad0c19d3ec3e05fa25 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Sun, 14 Jun 2026 18:09:26 -0700 Subject: [PATCH] fix(reply): avoid bundled channel load in dedupe (#93104) --- src/auto-reply/reply/reply-payloads-dedupe.ts | 9 +++++---- src/auto-reply/reply/reply-payloads.test.ts | 17 +++-------------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/auto-reply/reply/reply-payloads-dedupe.ts b/src/auto-reply/reply/reply-payloads-dedupe.ts index 1822f0f96bd..083ea8f4f70 100644 --- a/src/auto-reply/reply/reply-payloads-dedupe.ts +++ b/src/auto-reply/reply/reply-payloads-dedupe.ts @@ -5,7 +5,6 @@ import { } from "@openclaw/normalization-core/string-coerce"; import { isMessagingToolDuplicate } from "../../agents/embedded-agent-helpers.js"; import type { MessagingToolSend } from "../../agents/embedded-agent-messaging.types.js"; -import { getChannelPlugin } from "../../channels/plugins/index.js"; import { getLoadedChannelPluginForRead } from "../../channels/plugins/registry-loaded-read.js"; import { normalizeAnyChannelId } from "../../channels/registry.js"; import type { OpenClawConfig } from "../../config/types.openclaw.js"; @@ -189,7 +188,8 @@ function targetsMatchForDedupe(params: { targetKey: string; targetThreadId?: string; }): boolean { - const pluginMatch = getChannelPlugin(params.provider)?.outbound?.targetsMatchForReplySuppression; + const pluginMatch = getLoadedChannelPluginForRead(params.provider)?.outbound + ?.targetsMatchForReplySuppression; if (pluginMatch) { return pluginMatch({ originTarget: params.originTarget, @@ -214,7 +214,8 @@ function resolveOriginThreadIdForPayload(params: { return originThreadId; } const replyToId = normalizeThreadIdForComparison(params.replyToId); - const resolveReplyTransport = getChannelPlugin(params.provider)?.threading?.resolveReplyTransport; + const resolveReplyTransport = getLoadedChannelPluginForRead(params.provider)?.threading + ?.resolveReplyTransport; if (!replyToId || !params.config || !resolveReplyTransport) { return originThreadId; } @@ -325,7 +326,7 @@ export function getMatchingMessagingToolReplyTargets(params: { // that encode the thread/topic inside the target string carry their own // matcher and must still run it. const hasPluginThreadMatcher = Boolean( - getChannelPlugin(provider)?.outbound?.targetsMatchForReplySuppression, + getLoadedChannelPluginForRead(provider)?.outbound?.targetsMatchForReplySuppression, ); if (!hasPluginThreadMatcher && (originRoute.threadId != null || targetRoute.threadId != null)) { return false; diff --git a/src/auto-reply/reply/reply-payloads.test.ts b/src/auto-reply/reply/reply-payloads.test.ts index 071422b1955..7218b8843c3 100644 --- a/src/auto-reply/reply/reply-payloads.test.ts +++ b/src/auto-reply/reply/reply-payloads.test.ts @@ -1,5 +1,5 @@ // Tests reply payload helper behavior and delivery metadata. -import { describe, expect, it, vi } from "vitest"; +import { describe, expect, it } from "vitest"; import { resetPluginRuntimeStateForTest, setActivePluginRegistry } from "../../plugins/runtime.js"; import { createOutboundTestPlugin, createTestRegistry } from "../../test-utils/channel-plugins.js"; import { getReplyPayloadMetadata, setReplyPayloadMetadata } from "../reply-payload.js"; @@ -26,17 +26,6 @@ function targetsMatchTelegramReplySuppression(params: { ); } -vi.mock("../../channels/plugins/bundled.js", () => ({ - getBundledChannelPlugin: (channel: string) => - channel === "telegram" - ? { - outbound: { - targetsMatchForReplySuppression: targetsMatchTelegramReplySuppression, - }, - } - : undefined, -})); - describe("filterMessagingToolMediaDuplicates", () => { it("strips mediaUrl when it matches sentMediaUrls", () => { const result = filterMessagingToolMediaDuplicates({ @@ -262,7 +251,7 @@ describe("shouldDedupeMessagingToolRepliesForRoute", () => { ).toBe(true); }); - it("matches telegram replies even when the active plugin registry omits telegram", () => { + it("uses generic route matching when the active plugin registry omits telegram", () => { resetPluginRuntimeStateForTest(); setActivePluginRegistry(createTestRegistry([])); @@ -274,7 +263,7 @@ describe("shouldDedupeMessagingToolRepliesForRoute", () => { { tool: "message", provider: "telegram", to: "-100123", threadId: "77" }, ], }), - ).toBe(true); + ).toBe(false); }); });