





















@@ -1,4 +1,5 @@
11import { beforeEach, describe, expect, it, vi } from "vitest";
2+import { logVerbose } from "../../globals.js";
23import type { MsgContext } from "../templating.js";
34import { withFastReplyConfig } from "./get-reply-fast-path.js";
45import {
@@ -74,6 +75,7 @@ describe("getReplyFromConfig message hooks", () => {
7475mocks.triggerInternalHook.mockReset();
7576mocks.resolveReplyDirectives.mockReset();
7677mocks.initSessionState.mockReset();
78+vi.mocked(logVerbose).mockReset();
77797880mocks.applyMediaUnderstanding.mockImplementation(async (...args: unknown[]) => {
7981const { ctx } = args[0] as { ctx: MsgContext };
@@ -198,4 +200,62 @@ describe("getReplyFromConfig message hooks", () => {
198200expect(mocks.applyMediaUnderstanding).not.toHaveBeenCalled();
199201expect(mocks.applyLinkUnderstanding).not.toHaveBeenCalled();
200202});
203+204+it("continues dispatching when media understanding fails before reply routing", async () => {
205+mocks.applyMediaUnderstanding.mockRejectedValueOnce(
206+new Error("Cannot find module '/tmp/openclaw/dist/media-understanding/apply.runtime-old.js'"),
207+);
208+209+const reply = await getReplyFromConfig(buildCtx(), undefined, withFastReplyConfig({}));
210+211+expect(reply).toEqual({ text: "ok" });
212+expect(mocks.applyMediaUnderstanding).toHaveBeenCalledTimes(1);
213+expect(mocks.initSessionState).toHaveBeenCalledTimes(1);
214+expect(mocks.resolveReplyDirectives).toHaveBeenCalledTimes(1);
215+expect(mocks.createInternalHookEvent).toHaveBeenCalledTimes(1);
216+expect(mocks.createInternalHookEvent).toHaveBeenCalledWith(
217+"message",
218+"preprocessed",
219+"agent:main:telegram:-100123",
220+expect.any(Object),
221+);
222+expect(logVerbose).toHaveBeenCalledWith(
223+expect.stringContaining("media understanding failed, proceeding with raw content"),
224+);
225+});
226+227+it("continues dispatching URL messages when link understanding fails before reply routing", async () => {
228+mocks.applyLinkUnderstanding.mockRejectedValueOnce(
229+new Error("Cannot find module '/tmp/openclaw/dist/link-understanding/apply.runtime-old.js'"),
230+);
231+232+const reply = await getReplyFromConfig(
233+buildCtx({
234+Body: "read https://example.test/page",
235+BodyForAgent: "read https://example.test/page",
236+RawBody: "read https://example.test/page",
237+CommandBody: "read https://example.test/page",
238+BodyForCommands: "read https://example.test/page",
239+MediaPath: undefined,
240+MediaUrl: undefined,
241+MediaPaths: undefined,
242+MediaUrls: undefined,
243+MediaTypes: undefined,
244+MediaType: undefined,
245+Sticker: undefined,
246+StickerMediaIncluded: undefined,
247+}),
248+undefined,
249+withFastReplyConfig({}),
250+);
251+252+expect(reply).toEqual({ text: "ok" });
253+expect(mocks.applyMediaUnderstanding).not.toHaveBeenCalled();
254+expect(mocks.applyLinkUnderstanding).toHaveBeenCalledTimes(1);
255+expect(mocks.initSessionState).toHaveBeenCalledTimes(1);
256+expect(mocks.resolveReplyDirectives).toHaveBeenCalledTimes(1);
257+expect(logVerbose).toHaveBeenCalledWith(
258+expect.stringContaining("link understanding failed, proceeding with raw content"),
259+);
260+});
201261});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。