
























@@ -24,6 +24,28 @@ vi.mock("../../secrets/runtime.js", () => ({
2424getActiveSecretsRuntimeSnapshot: mocks.getActiveSecretsRuntimeSnapshot,
2525}));
262627+type RunWebSearchParams = {
28+config?: unknown;
29+preferRuntimeProviders?: boolean;
30+runtimeWebSearch?: {
31+selectedProvider?: string;
32+};
33+};
34+35+type ProviderResolutionParams = {
36+value?: string;
37+};
38+39+function firstRunWebSearchParams(): RunWebSearchParams | undefined {
40+return mocks.runWebSearch.mock.calls[0]?.[0] as RunWebSearchParams | undefined;
41+}
42+43+function firstProviderResolutionParams(): ProviderResolutionParams | undefined {
44+return mocks.resolveManifestContractOwnerPluginId.mock.calls[0]?.[0] as
45+| ProviderResolutionParams
46+| undefined;
47+}
48+2749describe("web_search late-bound runtime fallback", () => {
2850beforeEach(() => {
2951mocks.runWebSearch.mockReset();
@@ -54,11 +76,7 @@ describe("web_search late-bound runtime fallback", () => {
54765577await tool?.execute("call-search", { query: "openclaw" }, undefined);
567857-expect(mocks.runWebSearch).toHaveBeenCalledWith(
58-expect.objectContaining({
59-runtimeWebSearch: expect.objectContaining({ selectedProvider: "brave" }),
60-}),
61-);
79+expect(firstRunWebSearchParams()?.runtimeWebSearch?.selectedProvider).toBe("brave");
6280});
63816482it("falls back to options.config when getActiveSecretsRuntimeSnapshot is null", async () => {
@@ -73,11 +91,7 @@ describe("web_search late-bound runtime fallback", () => {
73917492await tool?.execute("call-search", { query: "openclaw" }, undefined);
759376-expect(mocks.runWebSearch).toHaveBeenCalledWith(
77-expect.objectContaining({
78-config: fallbackConfig,
79-}),
80-);
94+expect(firstRunWebSearchParams()?.config).toBe(fallbackConfig);
8195});
82968397it("uses configured provider id from config when no runtime selection is present", async () => {
@@ -92,12 +106,8 @@ describe("web_search late-bound runtime fallback", () => {
9210693107await tool?.execute("call-search", { query: "openclaw" }, undefined);
9410895-expect(mocks.resolveManifestContractOwnerPluginId).toHaveBeenCalledWith(
96-expect.objectContaining({ value: "brave" }),
97-);
98-expect(mocks.runWebSearch).toHaveBeenCalledWith(
99-expect.objectContaining({ preferRuntimeProviders: true }),
100-);
109+expect(firstProviderResolutionParams()?.value).toBe("brave");
110+expect(firstRunWebSearchParams()?.preferRuntimeProviders).toBe(true);
101111});
102112103113it("keeps runtime provider discovery enabled when no provider id is selected anywhere", async () => {
@@ -110,9 +120,7 @@ describe("web_search late-bound runtime fallback", () => {
110120await tool?.execute("call-search", { query: "openclaw" }, undefined);
111121112122expect(mocks.resolveManifestContractOwnerPluginId).not.toHaveBeenCalled();
113-expect(mocks.runWebSearch).toHaveBeenCalledWith(
114-expect.objectContaining({ preferRuntimeProviders: true }),
115-);
123+expect(firstRunWebSearchParams()?.preferRuntimeProviders).toBe(true);
116124});
117125118126it("does not prefer runtime providers when the configured provider is a bundled manifest owner", async () => {
@@ -128,9 +136,7 @@ describe("web_search late-bound runtime fallback", () => {
128136129137await tool?.execute("call-search", { query: "openclaw" }, undefined);
130138131-expect(mocks.runWebSearch).toHaveBeenCalledWith(
132-expect.objectContaining({ preferRuntimeProviders: false }),
133-);
139+expect(firstRunWebSearchParams()?.preferRuntimeProviders).toBe(false);
134140});
135141136142it("prefers active runtime metadata over options.runtimeWebSearch when present", async () => {
@@ -156,11 +162,7 @@ describe("web_search late-bound runtime fallback", () => {
156162157163await tool?.execute("call-search", { query: "openclaw" }, undefined);
158164159-expect(mocks.runWebSearch).toHaveBeenCalledWith(
160-expect.objectContaining({
161-runtimeWebSearch: expect.objectContaining({ selectedProvider: "perplexity" }),
162-}),
163-);
165+expect(firstRunWebSearchParams()?.runtimeWebSearch?.selectedProvider).toBe("perplexity");
164166});
165167166168it("honors late-bound disabled search config at execute time", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。