惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
GbyAI
GbyAI
Google DeepMind News
Google DeepMind News
Jina AI
Jina AI
B
Blog
aimingoo的专栏
aimingoo的专栏
酷 壳 – CoolShell
酷 壳 – CoolShell
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI
月光博客
月光博客
H
Help Net Security
V
Visual Studio Blog
量子位
A
About on SuperTechFans
博客园 - Franky
人人都是产品经理
人人都是产品经理
N
Netflix TechBlog - Medium
云风的 BLOG
云风的 BLOG
雷峰网
雷峰网
Martin Fowler
Martin Fowler
Microsoft Security Blog
Microsoft Security Blog
博客园 - 叶小钗
P
Proofpoint News Feed
MongoDB | Blog
MongoDB | Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(gemini): reuse google provider config for web search ...
steipete · 2026-05-02 · via Recent Commits to openclaw:main

@@ -1,3 +1,4 @@

1+

import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";

12

import {

23

createWebSearchProviderContractFields,

34

mergeScopedSearchConfig,

@@ -12,6 +13,7 @@ import {

1213

} from "./gemini-web-search-provider.shared.js";

13141415

const GEMINI_CREDENTIAL_PATH = "plugins.entries.google.config.webSearch.apiKey";

16+

const GOOGLE_PROVIDER_CREDENTIAL_PATH = "models.providers.google.apiKey";

15171618

type GeminiWebSearchRuntime = typeof import("./gemini-web-search-provider.runtime.js");

1719

@@ -64,7 +66,54 @@ function createGeminiToolDefinition(

6466

};

6567

}

666869+

function isRecord(value: unknown): value is Record<string, unknown> {

70+

return typeof value === "object" && value !== null && !Array.isArray(value);

71+

}

72+73+

function resolveGoogleModelProviderConfig(

74+

config?: OpenClawConfig,

75+

): Record<string, unknown> | undefined {

76+

const provider = config?.models?.providers?.google;

77+

return isRecord(provider) ? provider : undefined;

78+

}

79+80+

function getGoogleModelProviderCredentialFallback(

81+

config?: OpenClawConfig,

82+

): { path: string; value: unknown } | undefined {

83+

const provider = resolveGoogleModelProviderConfig(config);

84+

return provider && provider.apiKey !== undefined

85+

? { path: GOOGLE_PROVIDER_CREDENTIAL_PATH, value: provider.apiKey }

86+

: undefined;

87+

}

88+89+

function withGoogleModelProviderFallbacks(

90+

searchConfig: Record<string, unknown> | undefined,

91+

config?: OpenClawConfig,

92+

): Record<string, unknown> | undefined {

93+

const provider = resolveGoogleModelProviderConfig(config);

94+

if (!provider || (provider.apiKey === undefined && provider.baseUrl === undefined)) {

95+

return searchConfig;

96+

}

97+

const gemini = isRecord(searchConfig?.gemini) ? { ...searchConfig.gemini } : {};

98+

if (provider.apiKey !== undefined) {

99+

gemini.providerApiKey = provider.apiKey;

100+

}

101+

if (provider.baseUrl !== undefined) {

102+

gemini.providerBaseUrl = provider.baseUrl;

103+

}

104+

return {

105+

...(searchConfig ?? {}),

106+

gemini,

107+

};

108+

}

109+67110

export function createGeminiWebSearchProvider(): WebSearchProviderPlugin {

111+

const contractFields = createWebSearchProviderContractFields({

112+

credentialPath: GEMINI_CREDENTIAL_PATH,

113+

searchCredential: { type: "scoped", scopeId: "gemini" },

114+

configuredCredential: { pluginId: "google" },

115+

});

116+68117

return {

69118

id: "gemini",

70119

label: "Gemini (Google Search)",

@@ -77,17 +126,17 @@ export function createGeminiWebSearchProvider(): WebSearchProviderPlugin {

77126

docsUrl: "https://docs.openclaw.ai/tools/web",

78127

autoDetectOrder: 20,

79128

credentialPath: GEMINI_CREDENTIAL_PATH,

80-

...createWebSearchProviderContractFields({

81-

credentialPath: GEMINI_CREDENTIAL_PATH,

82-

searchCredential: { type: "scoped", scopeId: "gemini" },

83-

configuredCredential: { pluginId: "google" },

84-

}),

129+

...contractFields,

130+

getConfiguredCredentialFallback: getGoogleModelProviderCredentialFallback,

85131

createTool: (ctx) =>

86132

createGeminiToolDefinition(

87-

mergeScopedSearchConfig(

88-

ctx.searchConfig,

89-

"gemini",

90-

resolveProviderWebSearchPluginConfig(ctx.config, "google"),

133+

withGoogleModelProviderFallbacks(

134+

mergeScopedSearchConfig(

135+

ctx.searchConfig,

136+

"gemini",

137+

resolveProviderWebSearchPluginConfig(ctx.config, "google"),

138+

),

139+

ctx.config,

91140

),

92141

),

93142

};