Skip to content

Commit 8406cff

Browse files
committed
fix(reply): avoid bundled channel load in dedupe
1 parent e82d19f commit 8406cff

2 files changed

Lines changed: 8 additions & 18 deletions

File tree

src/auto-reply/reply/reply-payloads-dedupe.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
} from "@openclaw/normalization-core/string-coerce";
66
import { isMessagingToolDuplicate } from "../../agents/embedded-agent-helpers.js";
77
import type { MessagingToolSend } from "../../agents/embedded-agent-messaging.types.js";
8-
import { getChannelPlugin } from "../../channels/plugins/index.js";
98
import { getLoadedChannelPluginForRead } from "../../channels/plugins/registry-loaded-read.js";
109
import { normalizeAnyChannelId } from "../../channels/registry.js";
1110
import type { OpenClawConfig } from "../../config/types.openclaw.js";
@@ -189,7 +188,8 @@ function targetsMatchForDedupe(params: {
189188
targetKey: string;
190189
targetThreadId?: string;
191190
}): boolean {
192-
const pluginMatch = getChannelPlugin(params.provider)?.outbound?.targetsMatchForReplySuppression;
191+
const pluginMatch = getLoadedChannelPluginForRead(params.provider)?.outbound
192+
?.targetsMatchForReplySuppression;
193193
if (pluginMatch) {
194194
return pluginMatch({
195195
originTarget: params.originTarget,
@@ -214,7 +214,8 @@ function resolveOriginThreadIdForPayload(params: {
214214
return originThreadId;
215215
}
216216
const replyToId = normalizeThreadIdForComparison(params.replyToId);
217-
const resolveReplyTransport = getChannelPlugin(params.provider)?.threading?.resolveReplyTransport;
217+
const resolveReplyTransport = getLoadedChannelPluginForRead(params.provider)?.threading
218+
?.resolveReplyTransport;
218219
if (!replyToId || !params.config || !resolveReplyTransport) {
219220
return originThreadId;
220221
}
@@ -325,7 +326,7 @@ export function getMatchingMessagingToolReplyTargets(params: {
325326
// that encode the thread/topic inside the target string carry their own
326327
// matcher and must still run it.
327328
const hasPluginThreadMatcher = Boolean(
328-
getChannelPlugin(provider)?.outbound?.targetsMatchForReplySuppression,
329+
getLoadedChannelPluginForRead(provider)?.outbound?.targetsMatchForReplySuppression,
329330
);
330331
if (!hasPluginThreadMatcher && (originRoute.threadId != null || targetRoute.threadId != null)) {
331332
return false;

src/auto-reply/reply/reply-payloads.test.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Tests reply payload helper behavior and delivery metadata.
2-
import { describe, expect, it, vi } from "vitest";
2+
import { describe, expect, it } from "vitest";
33
import { resetPluginRuntimeStateForTest, setActivePluginRegistry } from "../../plugins/runtime.js";
44
import { createOutboundTestPlugin, createTestRegistry } from "../../test-utils/channel-plugins.js";
55
import { getReplyPayloadMetadata, setReplyPayloadMetadata } from "../reply-payload.js";
@@ -26,17 +26,6 @@ function targetsMatchTelegramReplySuppression(params: {
2626
);
2727
}
2828

29-
vi.mock("../../channels/plugins/bundled.js", () => ({
30-
getBundledChannelPlugin: (channel: string) =>
31-
channel === "telegram"
32-
? {
33-
outbound: {
34-
targetsMatchForReplySuppression: targetsMatchTelegramReplySuppression,
35-
},
36-
}
37-
: undefined,
38-
}));
39-
4029
describe("filterMessagingToolMediaDuplicates", () => {
4130
it("strips mediaUrl when it matches sentMediaUrls", () => {
4231
const result = filterMessagingToolMediaDuplicates({
@@ -262,7 +251,7 @@ describe("shouldDedupeMessagingToolRepliesForRoute", () => {
262251
).toBe(true);
263252
});
264253

265-
it("matches telegram replies even when the active plugin registry omits telegram", () => {
254+
it("uses generic route matching when the active plugin registry omits telegram", () => {
266255
resetPluginRuntimeStateForTest();
267256
setActivePluginRegistry(createTestRegistry([]));
268257

@@ -274,7 +263,7 @@ describe("shouldDedupeMessagingToolRepliesForRoute", () => {
274263
{ tool: "message", provider: "telegram", to: "-100123", threadId: "77" },
275264
],
276265
}),
277-
).toBe(true);
266+
).toBe(false);
278267
});
279268
});
280269

0 commit comments

Comments
 (0)