diff --git a/CHANGELOG.md b/CHANGELOG.md index cc2fe7b2f23..b61abe98104 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ Docs: https://docs.openclaw.ai - Providers/xAI: give Grok `web_search` a 60s default timeout, harden malformed xAI Responses parsing, and return structured timeout errors instead of aborting the tool call. Fixes #58063 and #58733. Thanks @dnishimura, @marvcasasola-svg, and @Nanako0129. - Providers/configure: preserve the existing default model when adding or reauthing a provider whose plugin returns a default-model config patch. Fixes #50268. Thanks @rixcorp-oc. - Slack/message tool: let `read` fetch an exact Slack message timestamp, including a specific thread reply when paired with `threadId`, instead of returning only the parent thread or recent channel history. Fixes #53943. Thanks @zomars. +- Web search: point missing-key errors to `web_fetch` for known URLs and the browser tool for interactive pages. Thanks @zhaoyang97. - Heartbeat: strip legacy `[TOOL_CALL]...[/TOOL_CALL]` and `[TOOL_RESULT]...[/TOOL_RESULT]` pseudo-call blocks from heartbeat replies before channel delivery. Fixes #54138. Thanks @Deniable9570. - macOS/Voice Wake: send wake-word and Push-to-Talk transcripts through the selected macOS session target instead of always falling back to main WebChat. Fixes #51040. Thanks @carl-jeffrolc. - Providers/xAI: give Grok `web_search` a 60s default timeout, harden malformed xAI Responses parsing, and return structured timeout errors instead of aborting the tool call. Fixes #58063 and #58733. Thanks @dnishimura, @marvcasasola-svg, and @Nanako0129. diff --git a/extensions/brave/src/brave-web-search-provider.runtime.ts b/extensions/brave/src/brave-web-search-provider.runtime.ts index 4785d81b027..43db33fd5b3 100644 --- a/extensions/brave/src/brave-web-search-provider.runtime.ts +++ b/extensions/brave/src/brave-web-search-provider.runtime.ts @@ -53,7 +53,7 @@ function resolveBraveApiKey(searchConfig?: SearchConfigRecord): string | undefin function missingBraveKeyPayload() { return { error: "missing_brave_api_key", - message: `web_search (brave) needs a Brave Search API key. Run \`${formatCliCommand("openclaw configure --section web")}\` to store it, or set BRAVE_API_KEY in the Gateway environment.`, + message: `web_search (brave) needs a Brave Search API key. Run \`${formatCliCommand("openclaw configure --section web")}\` to store it, or set BRAVE_API_KEY in the Gateway environment. If you do not want to configure a search API key, use web_fetch for a specific URL or the browser tool for interactive pages.`, docs: "https://docs.openclaw.ai/tools/web", }; } diff --git a/extensions/brave/src/brave-web-search-provider.test.ts b/extensions/brave/src/brave-web-search-provider.test.ts index cfc351e848d..a29fd1f7192 100644 --- a/extensions/brave/src/brave-web-search-provider.test.ts +++ b/extensions/brave/src/brave-web-search-provider.test.ts @@ -18,6 +18,22 @@ describe("brave web search provider", () => { global.fetch = priorFetch; }); + it("points missing-key users to fetch/browser alternatives", async () => { + vi.stubEnv("BRAVE_API_KEY", ""); + const provider = createBraveWebSearchProvider(); + const tool = provider.createTool({ config: {}, searchConfig: {} }); + if (!tool) { + throw new Error("Expected tool definition"); + } + + const result = await tool.execute({ query: "OpenClaw docs" }); + + expect(result).toMatchObject({ + error: "missing_brave_api_key", + message: expect.stringContaining("use web_fetch for a specific URL or the browser tool"), + }); + }); + it("normalizes brave language parameters and swaps reversed ui/search inputs", () => { expect( __testing.normalizeBraveLanguageParams({ diff --git a/extensions/google/src/gemini-web-search-provider.runtime.ts b/extensions/google/src/gemini-web-search-provider.runtime.ts index dfb904a3397..defcc137f70 100644 --- a/extensions/google/src/gemini-web-search-provider.runtime.ts +++ b/extensions/google/src/gemini-web-search-provider.runtime.ts @@ -152,7 +152,7 @@ export async function executeGeminiSearch( return { error: "missing_gemini_api_key", message: - "web_search (gemini) needs an API key. Set GEMINI_API_KEY in the Gateway environment, or configure tools.web.search.gemini.apiKey.", + "web_search (gemini) needs an API key. Set GEMINI_API_KEY in the Gateway environment, or configure tools.web.search.gemini.apiKey. If you do not want to configure a search API key, use web_fetch for a specific URL or the browser tool for interactive pages.", docs: "https://docs.openclaw.ai/tools/web", }; } diff --git a/extensions/google/web-search-provider.test.ts b/extensions/google/web-search-provider.test.ts index fa6b7af6b68..93d546b65ab 100644 --- a/extensions/google/web-search-provider.test.ts +++ b/extensions/google/web-search-provider.test.ts @@ -1,9 +1,24 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types"; -import { withEnv } from "openclaw/plugin-sdk/test-env"; +import { withEnv, withEnvAsync } from "openclaw/plugin-sdk/test-env"; import { describe, expect, it } from "vitest"; import { __testing, createGeminiWebSearchProvider } from "./src/gemini-web-search-provider.js"; describe("google web search provider", () => { + it("points missing-key users to fetch/browser alternatives", async () => { + await withEnvAsync({ GEMINI_API_KEY: undefined }, async () => { + const provider = createGeminiWebSearchProvider(); + const tool = provider.createTool({ config: {}, searchConfig: {} }); + if (!tool) { + throw new Error("Expected tool definition"); + } + + await expect(tool.execute({ query: "OpenClaw docs" })).resolves.toMatchObject({ + error: "missing_gemini_api_key", + message: expect.stringContaining("use web_fetch for a specific URL or the browser tool"), + }); + }); + }); + it("falls back to GEMINI_API_KEY from the environment", () => { withEnv({ GEMINI_API_KEY: "AIza-env-test" }, () => { expect(__testing.resolveGeminiApiKey()).toBe("AIza-env-test"); diff --git a/extensions/moonshot/src/kimi-web-search-provider.runtime.ts b/extensions/moonshot/src/kimi-web-search-provider.runtime.ts index 8627a95378b..6e35319eaa4 100644 --- a/extensions/moonshot/src/kimi-web-search-provider.runtime.ts +++ b/extensions/moonshot/src/kimi-web-search-provider.runtime.ts @@ -274,7 +274,7 @@ export async function executeKimiWebSearchProviderTool( return { error: "missing_kimi_api_key", message: - "web_search (kimi) needs a Moonshot API key. Set KIMI_API_KEY or MOONSHOT_API_KEY in the Gateway environment, or configure tools.web.search.kimi.apiKey.", + "web_search (kimi) needs a Moonshot API key. Set KIMI_API_KEY or MOONSHOT_API_KEY in the Gateway environment, or configure tools.web.search.kimi.apiKey. If you do not want to configure a search API key, use web_fetch for a specific URL or the browser tool for interactive pages.", docs: "https://docs.openclaw.ai/tools/web", }; } diff --git a/extensions/moonshot/src/kimi-web-search-provider.test.ts b/extensions/moonshot/src/kimi-web-search-provider.test.ts index fcceab8480f..f6eaeab7ada 100644 --- a/extensions/moonshot/src/kimi-web-search-provider.test.ts +++ b/extensions/moonshot/src/kimi-web-search-provider.test.ts @@ -1,6 +1,8 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk/provider-onboard"; +import { withEnvAsync } from "openclaw/plugin-sdk/test-env"; import { describe, expect, it } from "vitest"; import { __testing } from "../test-api.js"; +import { createKimiWebSearchProvider } from "./kimi-web-search-provider.js"; const kimiApiKeyEnv = ["KIMI_API", "KEY"].join("_"); @@ -24,6 +26,23 @@ function withEnv(overrides: Record, run: () => void): void { } describe("kimi web search provider", () => { + it("points missing-key users to fetch/browser alternatives", async () => { + await withEnvAsync({ KIMI_API_KEY: undefined, MOONSHOT_API_KEY: undefined }, async () => { + const provider = createKimiWebSearchProvider(); + const tool = provider.createTool({ config: {}, searchConfig: {} }); + if (!tool) { + throw new Error("Expected tool definition"); + } + + const result = await tool.execute({ query: "OpenClaw docs" }); + + expect(result).toMatchObject({ + error: "missing_kimi_api_key", + message: expect.stringContaining("use web_fetch for a specific URL or the browser tool"), + }); + }); + }); + it("uses configured model and base url overrides with sane defaults", () => { expect(__testing.resolveKimiModel()).toBe("kimi-k2.6"); expect(__testing.resolveKimiModel({ model: "kimi-k2" })).toBe("kimi-k2"); diff --git a/extensions/perplexity/src/perplexity-web-search-provider.runtime.ts b/extensions/perplexity/src/perplexity-web-search-provider.runtime.ts index 1e4b0ce9d62..41e343cb6d6 100644 --- a/extensions/perplexity/src/perplexity-web-search-provider.runtime.ts +++ b/extensions/perplexity/src/perplexity-web-search-provider.runtime.ts @@ -308,7 +308,7 @@ export async function executePerplexitySearch( return { error: "missing_perplexity_api_key", message: - "web_search (perplexity) needs an API key. Set PERPLEXITY_API_KEY or OPENROUTER_API_KEY in the Gateway environment, or configure tools.web.search.perplexity.apiKey.", + "web_search (perplexity) needs an API key. Set PERPLEXITY_API_KEY or OPENROUTER_API_KEY in the Gateway environment, or configure tools.web.search.perplexity.apiKey. If you do not want to configure a search API key, use web_fetch for a specific URL or the browser tool for interactive pages.", docs: "https://docs.openclaw.ai/tools/web", }; } diff --git a/extensions/perplexity/src/perplexity-web-search-provider.test.ts b/extensions/perplexity/src/perplexity-web-search-provider.test.ts index 8724210859c..11f4bdf7cd5 100644 --- a/extensions/perplexity/src/perplexity-web-search-provider.test.ts +++ b/extensions/perplexity/src/perplexity-web-search-provider.test.ts @@ -1,5 +1,6 @@ -import { withEnv } from "openclaw/plugin-sdk/test-env"; +import { withEnv, withEnvAsync } from "openclaw/plugin-sdk/test-env"; import { describe, expect, it } from "vitest"; +import { createPerplexityWebSearchProvider } from "./perplexity-web-search-provider.js"; import { __testing } from "./perplexity-web-search-provider.runtime.js"; const openRouterApiKeyEnv = ["OPENROUTER_API", "KEY"].join("_"); @@ -9,6 +10,24 @@ const directPerplexityApiKey = ["pplx", "test"].join("-"); const enterprisePerplexityApiKey = ["enterprise", "perplexity", "test"].join("-"); describe("perplexity web search provider", () => { + it("points missing-key users to fetch/browser alternatives", async () => { + await withEnvAsync( + { [perplexityApiKeyEnv]: undefined, [openRouterApiKeyEnv]: undefined }, + async () => { + const provider = createPerplexityWebSearchProvider(); + const tool = provider.createTool({ config: {}, searchConfig: {} }); + if (!tool) { + throw new Error("Expected tool definition"); + } + + await expect(tool.execute({ query: "OpenClaw docs" })).resolves.toMatchObject({ + error: "missing_perplexity_api_key", + message: expect.stringContaining("use web_fetch for a specific URL or the browser tool"), + }); + }, + ); + }); + it("infers provider routing from api key prefixes", () => { expect(__testing.inferPerplexityBaseUrlFromApiKey("pplx-abc")).toBe("direct"); expect(__testing.inferPerplexityBaseUrlFromApiKey("sk-or-v1-abc")).toBe("openrouter"); diff --git a/extensions/xai/src/web-search-provider.runtime.ts b/extensions/xai/src/web-search-provider.runtime.ts index 8ce5829d07b..76601db9a3f 100644 --- a/extensions/xai/src/web-search-provider.runtime.ts +++ b/extensions/xai/src/web-search-provider.runtime.ts @@ -194,7 +194,7 @@ export async function executeXaiWebSearchProviderTool( return { error: "missing_xai_api_key", message: - "web_search (grok) needs an xAI API key. Set XAI_API_KEY in the Gateway environment, or configure plugins.entries.xai.config.webSearch.apiKey.", + "web_search (grok) needs an xAI API key. Set XAI_API_KEY in the Gateway environment, or configure plugins.entries.xai.config.webSearch.apiKey. If you do not want to configure a search API key, use web_fetch for a specific URL or the browser tool for interactive pages.", docs: "https://docs.openclaw.ai/tools/web", }; } diff --git a/extensions/xai/web-search.test.ts b/extensions/xai/web-search.test.ts index 3c6c7a71a73..290b6a9ab7c 100644 --- a/extensions/xai/web-search.test.ts +++ b/extensions/xai/web-search.test.ts @@ -110,6 +110,7 @@ describe("xai web search config resolution", () => { await expect(maybeTool.execute({ query: "OpenClaw" })).resolves.toMatchObject({ error: "missing_xai_api_key", + message: expect.stringContaining("use web_fetch for a specific URL or the browser tool"), }); }); });