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

推荐订阅源

美团技术团队
T
The Blog of Author Tim Ferriss
C
Check Point Blog
博客园_首页
J
Java Code Geeks
云风的 BLOG
云风的 BLOG
L
LangChain Blog
小众软件
小众软件
Stack Overflow Blog
Stack Overflow Blog
爱范儿
爱范儿
Vercel News
Vercel News
博客园 - Franky
V
V2EX
IT之家
IT之家
U
Unit 42
N
Netflix TechBlog - Medium
腾讯CDC
Apple Machine Learning Research
Apple Machine Learning Research
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
博客园 - 叶小钗
H
Help Net Security
V
Visual Studio Blog
GbyAI
GbyAI

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(gateway): quarantine unsupported effective tool schem...
vincentkoc · 2026-05-28 · via Recent Commits to openclaw:main
11

import type { OpenClawConfig } from "../config/config.js";

22

import { extractModelCompat } from "../plugins/provider-model-compat.js";

3+

import type { ProviderRuntimeModel } from "../plugins/provider-runtime-model.types.js";

4+

import { normalizeProviderTransportWithPlugin } from "../plugins/provider-runtime.js";

35

import { getActivePluginRegistry } from "../plugins/runtime.js";

46

import { buildPluginToolMetadataKey, getPluginToolMeta } from "../plugins/tools.js";

57

import {

@@ -10,11 +12,18 @@ import { resolveAgentDir, resolveAgentWorkspaceDir, resolveSessionAgentId } from

1012

import { createOpenClawCodingTools } from "./agent-tools.js";

1113

import { resolveEffectiveToolPolicy } from "./agent-tools.policy.js";

1214

import { getChannelAgentToolMeta } from "./channel-tools.js";

15+

import { resolveModel } from "./embedded-agent-runner/model.js";

16+

import { resolveBundledStaticCatalogModel } from "./embedded-agent-runner/model.static-catalog.js";

1317

import { normalizeStaticProviderModelId } from "./model-ref-shared.js";

1418

import { findNormalizedProviderValue, normalizeProviderId } from "./provider-id.js";

19+

import { normalizeAgentRuntimeTools } from "./runtime-plan/tools.js";

1520

import { summarizeToolDescriptionText } from "./tool-description-summary.js";

1621

import { resolveToolDisplay } from "./tool-display.js";

1722

import { normalizeToolName } from "./tool-policy.js";

23+

import {

24+

filterRuntimeCompatibleTools,

25+

type RuntimeToolSchemaDiagnostic,

26+

} from "./tool-schema-projection.js";

1827

import type {

1928

EffectiveToolInventoryNotice,

2029

EffectiveToolInventoryEntry,

@@ -47,16 +56,22 @@ function summarizeToolDescription(tool: AnyAgentTool): string {

4756

});

4857

}

495850-

function resolveEffectiveToolSource(tool: AnyAgentTool): {

59+

function resolveEffectiveToolSource(

60+

tool: AnyAgentTool,

61+

fallbackTool?: AnyAgentTool,

62+

): {

5163

source: EffectiveToolSource;

5264

pluginId?: string;

5365

channelId?: string;

5466

} {

55-

const pluginMeta = getPluginToolMeta(tool);

67+

const pluginMeta =

68+

getPluginToolMeta(tool) ?? (fallbackTool ? getPluginToolMeta(fallbackTool) : undefined);

5669

if (pluginMeta) {

5770

return { source: "plugin", pluginId: pluginMeta.pluginId };

5871

}

59-

const channelMeta = getChannelAgentToolMeta(tool as never);

72+

const channelMeta =

73+

getChannelAgentToolMeta(tool as never) ??

74+

(fallbackTool ? getChannelAgentToolMeta(fallbackTool as never) : undefined);

6075

if (channelMeta) {

6176

return { source: "channel", channelId: channelMeta.channelId };

6277

}

@@ -150,6 +165,41 @@ function buildToolInventoryNotices(params: {

150165

return undefined;

151166

}

152167168+

function buildUnsupportedToolSchemaNotice(params: {

169+

diagnostic: RuntimeToolSchemaDiagnostic;

170+

tool: AnyAgentTool | undefined;

171+

fallbackTool: AnyAgentTool | undefined;

172+

}): EffectiveToolInventoryNotice {

173+

const source = params.tool

174+

? resolveEffectiveToolSource(params.tool, params.fallbackTool)

175+

: { source: "core" as const };

176+

const owner =

177+

source.source === "plugin" && source.pluginId

178+

? ` from plugin "${source.pluginId}"`

179+

: source.source === "channel" && source.channelId

180+

? ` from channel "${source.channelId}"`

181+

: "";

182+

return {

183+

id: `unsupported-tool-schema:${params.diagnostic.toolName}`,

184+

severity: "warning",

185+

message: `Tool "${params.diagnostic.toolName}"${owner} has an unsupported runtime input schema (${params.diagnostic.violations.join(", ")}) and was quarantined before model projection. Fix or disable the owner, or remove the tool from active allowlists.`,

186+

};

187+

}

188+189+

function buildUnsupportedToolSchemaNotices(params: {

190+

diagnostics: readonly RuntimeToolSchemaDiagnostic[];

191+

tools: readonly AnyAgentTool[];

192+

rawToolsByName: ReadonlyMap<string, AnyAgentTool>;

193+

}): EffectiveToolInventoryNotice[] {

194+

return params.diagnostics.map((diagnostic) =>

195+

buildUnsupportedToolSchemaNotice({

196+

diagnostic,

197+

tool: params.tools[diagnostic.toolIndex],

198+

fallbackTool: params.rawToolsByName.get(diagnostic.toolName),

199+

}),

200+

);

201+

}

202+153203

function disambiguateLabels(entries: EffectiveToolInventoryEntry[]): EffectiveToolInventoryEntry[] {

154204

const counts = new Map<string, number>();

155205

for (const entry of entries) {

@@ -164,6 +214,151 @@ function disambiguateLabels(entries: EffectiveToolInventoryEntry[]): EffectiveTo

164214

});

165215

}

166216217+

function applyProviderTransportNormalization(params: {

218+

cfg: OpenClawConfig;

219+

provider: string;

220+

workspaceDir?: string;

221+

runtimeModel: ProviderRuntimeModel;

222+

}): ProviderRuntimeModel {

223+

const normalized = normalizeProviderTransportWithPlugin({

224+

provider: params.provider,

225+

config: params.cfg,

226+

workspaceDir: params.workspaceDir,

227+

context: {

228+

config: params.cfg,

229+

workspaceDir: params.workspaceDir,

230+

provider: params.provider,

231+

api: params.runtimeModel.api,

232+

baseUrl: params.runtimeModel.baseUrl,

233+

},

234+

});

235+

if (!normalized) {

236+

return params.runtimeModel;

237+

}

238+

return {

239+

...params.runtimeModel,

240+

api: normalized.api ?? params.runtimeModel.api,

241+

baseUrl: normalized.baseUrl ?? params.runtimeModel.baseUrl,

242+

} as ProviderRuntimeModel;

243+

}

244+245+

function resolveConfiguredFallbackApi(

246+

providerConfig: { api?: string; baseUrl?: string } | undefined,

247+

): string {

248+

const explicitApi = normalizeOptionalString(providerConfig?.api);

249+

if (explicitApi) {

250+

return explicitApi;

251+

}

252+

return normalizeOptionalString(providerConfig?.baseUrl)

253+

? "openai-completions"

254+

: "openai-responses";

255+

}

256+257+

function resolveDynamicRuntimeModelContext(params: {

258+

cfg: OpenClawConfig;

259+

agentDir?: string;

260+

workspaceDir?: string;

261+

provider: string;

262+

modelId: string;

263+

}): { modelApi?: string; runtimeModel?: ProviderRuntimeModel } {

264+

const runtimeModel = resolveModel(params.provider, params.modelId, params.agentDir, params.cfg, {

265+

workspaceDir: params.workspaceDir,

266+

}).model as ProviderRuntimeModel | undefined;

267+

if (!runtimeModel) {

268+

return {};

269+

}

270+

return {

271+

modelApi: runtimeModel.api,

272+

runtimeModel,

273+

};

274+

}

275+276+

export function resolveEffectiveToolInventoryRuntimeModelContext(params: {

277+

cfg: OpenClawConfig;

278+

agentId?: string;

279+

agentDir?: string;

280+

workspaceDir?: string;

281+

modelProvider?: string;

282+

modelId?: string;

283+

}): { modelApi?: string; runtimeModel?: ProviderRuntimeModel } {

284+

const provider = normalizeProviderId(params.modelProvider ?? "");

285+

const modelId = params.modelId?.trim() ?? "";

286+

if (!provider || !modelId) {

287+

return {};

288+

}

289+

const agentId = params.agentId?.trim() || resolveSessionAgentId({ config: params.cfg });

290+

const workspaceDir = params.workspaceDir ?? resolveAgentWorkspaceDir(params.cfg, agentId);

291+

const providerConfig = findNormalizedProviderValue(params.cfg.models?.providers, provider);

292+

const configuredModels = Array.isArray(providerConfig?.models) ? providerConfig.models : [];

293+

const normalizedModelId = normalizeStaticProviderModelId(provider, modelId);

294+

const normalizedModelKey = normalizeLowercaseStringOrEmpty(normalizedModelId);

295+

const providerPrefixedModelKey = normalizeLowercaseStringOrEmpty(

296+

`${provider}/${normalizedModelId}`,

297+

);

298+

const configuredModel = configuredModels.find((model) => {

299+

const id = normalizeStaticProviderModelId(provider, model.id);

300+

const key = normalizeLowercaseStringOrEmpty(id);

301+

return key === normalizedModelKey || key === providerPrefixedModelKey;

302+

});

303+

const bundledStaticModel = resolveBundledStaticCatalogModel({

304+

provider,

305+

modelId,

306+

cfg: params.cfg,

307+

workspaceDir,

308+

}) as ProviderRuntimeModel | undefined;

309+

if (configuredModel) {

310+

const configuredApi =

311+

normalizeOptionalString(configuredModel.api) ??

312+

normalizeOptionalString(providerConfig?.api) ??

313+

normalizeOptionalString(bundledStaticModel?.api) ??

314+

resolveConfiguredFallbackApi(providerConfig);

315+

const runtimeModel = applyProviderTransportNormalization({

316+

cfg: params.cfg,

317+

provider,

318+

workspaceDir,

319+

runtimeModel: {

320+

...bundledStaticModel,

321+

...configuredModel,

322+

id: configuredModel.id,

323+

name: configuredModel.name ?? bundledStaticModel?.name ?? configuredModel.id,

324+

provider,

325+

api: configuredApi,

326+

baseUrl:

327+

normalizeOptionalString(configuredModel.baseUrl) ??

328+

normalizeOptionalString(providerConfig?.baseUrl) ??

329+

normalizeOptionalString(bundledStaticModel?.baseUrl),

330+

} as ProviderRuntimeModel,

331+

});

332+

return {

333+

modelApi: runtimeModel.api,

334+

runtimeModel,

335+

};

336+

}

337+

if (!bundledStaticModel) {

338+

return resolveDynamicRuntimeModelContext({

339+

cfg: params.cfg,

340+

agentDir: params.agentDir,

341+

workspaceDir,

342+

provider,

343+

modelId,

344+

});

345+

}

346+

const runtimeModel = applyProviderTransportNormalization({

347+

cfg: params.cfg,

348+

provider,

349+

workspaceDir,

350+

runtimeModel: {

351+

...bundledStaticModel,

352+

api: normalizeOptionalString(providerConfig?.api) ?? bundledStaticModel.api,

353+

baseUrl: normalizeOptionalString(providerConfig?.baseUrl) ?? bundledStaticModel.baseUrl,

354+

} as ProviderRuntimeModel,

355+

});

356+

return {

357+

modelApi: runtimeModel.api,

358+

runtimeModel,

359+

};

360+

}

361+167362

function resolveEffectiveModelCompat(params: {

168363

cfg: OpenClawConfig;

169364

modelProvider?: string;

@@ -200,6 +395,20 @@ export function resolveEffectiveToolInventory(

200395

resolveSessionAgentId({ sessionKey: params.sessionKey, config: params.cfg });

201396

const workspaceDir = params.workspaceDir ?? resolveAgentWorkspaceDir(params.cfg, agentId);

202397

const agentDir = params.agentDir ?? resolveAgentDir(params.cfg, agentId);

398+

const runtimeModelContext =

399+

params.modelApi || params.runtimeModel

400+

? {

401+

modelApi: params.modelApi ?? params.runtimeModel?.api,

402+

runtimeModel: params.runtimeModel,

403+

}

404+

: resolveEffectiveToolInventoryRuntimeModelContext({

405+

cfg: params.cfg,

406+

agentId,

407+

agentDir,

408+

workspaceDir,

409+

modelProvider: params.modelProvider,

410+

modelId: params.modelId,

411+

});

203412

const modelCompat = resolveEffectiveModelCompat({

204413

cfg: params.cfg,

205414

modelProvider: params.modelProvider,

@@ -214,6 +423,7 @@ export function resolveEffectiveToolInventory(

214423

config: params.cfg,

215424

modelProvider: params.modelProvider,

216425

modelId: params.modelId,

426+

modelApi: runtimeModelContext.modelApi,

217427

modelCompat,

218428

messageProvider: params.messageProvider,

219429

senderId: params.senderId,

@@ -233,6 +443,17 @@ export function resolveEffectiveToolInventory(

233443

requireExplicitMessageTarget: params.requireExplicitMessageTarget,

234444

disableMessageTool: params.disableMessageTool,

235445

});

446+

const rawToolsByName = new Map(effectiveTools.map((tool) => [tool.name, tool]));

447+

const normalizedEffectiveTools = normalizeAgentRuntimeTools({

448+

tools: effectiveTools,

449+

provider: params.modelProvider ?? "",

450+

config: params.cfg,

451+

workspaceDir,

452+

modelId: params.modelId,

453+

modelApi: runtimeModelContext.modelApi,

454+

model: runtimeModelContext.runtimeModel,

455+

});

456+

const toolSchemaProjection = filterRuntimeCompatibleTools(normalizedEffectiveTools);

236457

const effectivePolicy = resolveEffectiveToolPolicy({

237458

config: params.cfg,

238459

agentId,

@@ -251,9 +472,9 @@ export function resolveEffectiveToolInventory(

251472

);

252473253474

const entries = disambiguateLabels(

254-

effectiveTools

475+

toolSchemaProjection.tools

255476

.map((tool) => {

256-

const source = resolveEffectiveToolSource(tool);

477+

const source = resolveEffectiveToolSource(tool, rawToolsByName.get(tool.name));

257478

const metadata = source.pluginId

258479

? pluginToolMetadata.get(buildPluginToolMetadataKey(source.pluginId, tool.name))

259480

: undefined;

@@ -276,7 +497,14 @@ export function resolveEffectiveToolInventory(

276497

})

277498

.toSorted((a, b) => a.label.localeCompare(b.label)),

278499

);

279-

const notices = buildToolInventoryNotices({ cfg: params.cfg, profile, entries, effectivePolicy });

500+

const notices = [

501+

...buildUnsupportedToolSchemaNotices({

502+

diagnostics: toolSchemaProjection.diagnostics,

503+

tools: normalizedEffectiveTools,

504+

rawToolsByName,

505+

}),

506+

...(buildToolInventoryNotices({ cfg: params.cfg, profile, entries, effectivePolicy }) ?? []),

507+

];

280508

const groupsBySource = new Map<EffectiveToolSource, EffectiveToolInventoryEntry[]>();

281509

for (const entry of entries) {

282510

const tools = groupsBySource.get(entry.source) ?? [];

@@ -299,5 +527,5 @@ export function resolveEffectiveToolInventory(

299527

})

300528

.filter((group): group is EffectiveToolInventoryGroup => group !== null);

301529302-

return { agentId, profile, groups, ...(notices ? { notices } : {}) };

530+

return { agentId, profile, groups, ...(notices.length > 0 ? { notices } : {}) };

303531

}