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

推荐订阅源

D
DataBreaches.Net
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
云风的 BLOG
云风的 BLOG
B
Blog
博客园 - Franky
I
InfoQ
A
About on SuperTechFans
博客园_首页
L
LangChain Blog
量子位
腾讯CDC
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
美团技术团队
V
V2EX
Apple Machine Learning Research
Apple Machine Learning Research
雷峰网
雷峰网
MongoDB | Blog
MongoDB | Blog
Microsoft Azure Blog
Microsoft Azure Blog
月光博客
月光博客
T
The Blog of Author Tim Ferriss
P
Proofpoint News Feed
G
Google Developers Blog
Last Week in AI
Last Week in AI

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): skip stale model provider api entries · ope...
obviyus · 2026-04-27 · via Recent Commits to openclaw:main

@@ -10,9 +10,11 @@ import {

1010

recoverConfigFromLastKnownGood,

1111

recoverConfigFromJsonRootSuffix,

1212

shouldAttemptLastKnownGoodRecovery,

13+

validateConfigObjectWithPlugins,

1314

writeConfigFile,

1415

} from "../config/config.js";

1516

import { formatConfigIssueLines } from "../config/issue-format.js";

17+

import { asResolvedSourceConfig, materializeRuntimeConfig } from "../config/materialize.js";

1618

import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js";

1719

import { isTruthyEnvValue } from "../infra/env.js";

1820

import {

@@ -56,20 +58,122 @@ type GatewayStartupConfigOverrides = {

5658

export type GatewayStartupConfigSnapshotLoadResult = {

5759

snapshot: ConfigFileSnapshot;

5860

wroteConfig: boolean;

61+

degradedProviderApi?: boolean;

5962

};

606364+

const MODEL_PROVIDER_API_PATH_RE = /^models\.providers\.([^.]+)\.api$/;

65+

const MODEL_PROVIDER_MODEL_API_PATH_RE = /^models\.providers\.([^.]+)\.models\.\d+\.api$/;

66+67+

function resolveInvalidModelProviderApiIssueProviderId(issue: {

68+

path: string;

69+

message: string;

70+

}): string | null {

71+

if (!issue.message.startsWith("Invalid option:")) {

72+

return null;

73+

}

74+

const providerMatch =

75+

issue.path.match(MODEL_PROVIDER_API_PATH_RE) ??

76+

issue.path.match(MODEL_PROVIDER_MODEL_API_PATH_RE);

77+

return providerMatch?.[1] ?? null;

78+

}

79+80+

function cloneConfigWithoutModelProviders(

81+

config: OpenClawConfig,

82+

providerIds: ReadonlySet<string>,

83+

): OpenClawConfig {

84+

const providers = config.models?.providers;

85+

if (!providers) {

86+

return config;

87+

}

88+

let changed = false;

89+

const nextProviders = { ...providers };

90+

for (const providerId of providerIds) {

91+

if (!Object.hasOwn(nextProviders, providerId)) {

92+

continue;

93+

}

94+

delete nextProviders[providerId];

95+

changed = true;

96+

}

97+

if (!changed) {

98+

return config;

99+

}

100+

return {

101+

...config,

102+

models: {

103+

...config.models,

104+

providers: nextProviders,

105+

},

106+

};

107+

}

108+109+

function resolveGatewayStartupConfigWithoutInvalidModelProviders(params: {

110+

snapshot: ConfigFileSnapshot;

111+

log: GatewayStartupLog;

112+

}): ConfigFileSnapshot | null {

113+

if (params.snapshot.valid || params.snapshot.legacyIssues.length > 0) {

114+

return null;

115+

}

116+

const providerIds = new Set<string>();

117+

for (const issue of params.snapshot.issues) {

118+

const providerId = resolveInvalidModelProviderApiIssueProviderId(issue);

119+

if (!providerId) {

120+

return null;

121+

}

122+

providerIds.add(providerId);

123+

}

124+

if (providerIds.size === 0) {

125+

return null;

126+

}

127+128+

const prunedSourceConfig = cloneConfigWithoutModelProviders(

129+

params.snapshot.sourceConfig,

130+

providerIds,

131+

);

132+

const validated = validateConfigObjectWithPlugins(prunedSourceConfig);

133+

if (!validated.ok) {

134+

return null;

135+

}

136+

const runtimeConfig = materializeRuntimeConfig(validated.config, "load");

137+

for (const providerId of providerIds) {

138+

params.log.warn(

139+

`gateway: skipped model provider ${providerId}; configured provider api is invalid. Run "openclaw doctor --fix" to repair the config.`,

140+

);

141+

}

142+

return {

143+

...params.snapshot,

144+

sourceConfig: asResolvedSourceConfig(validated.config),

145+

resolved: asResolvedSourceConfig(validated.config),

146+

valid: true,

147+

runtimeConfig,

148+

config: runtimeConfig,

149+

issues: [],

150+

warnings: validated.warnings,

151+

};

152+

}

153+61154

export async function loadGatewayStartupConfigSnapshot(params: {

62155

minimalTestGateway: boolean;

63156

log: GatewayStartupLog;

64157

}): Promise<GatewayStartupConfigSnapshotLoadResult> {

65158

let configSnapshot = await readConfigFileSnapshot();

66159

let wroteConfig = false;

160+

let degradedStartupConfig = false;

67161

if (configSnapshot.legacyIssues.length > 0 && isNixMode) {

68162

throw new Error(

69163

"Legacy config entries detected while running in Nix mode. Update your Nix config to the latest schema and restart.",

70164

);

71165

}

72166

if (configSnapshot.exists) {

167+

if (!configSnapshot.valid) {

168+

const providerApiPrunedSnapshot = resolveGatewayStartupConfigWithoutInvalidModelProviders({

169+

snapshot: configSnapshot,

170+

log: params.log,

171+

});

172+

if (providerApiPrunedSnapshot) {

173+

degradedStartupConfig = true;

174+

configSnapshot = providerApiPrunedSnapshot;

175+

}

176+

}

73177

if (!configSnapshot.valid) {

74178

const canRecoverFromLastKnownGood = shouldAttemptLastKnownGoodRecovery(configSnapshot);

75179

const recovered = canRecoverFromLastKnownGood

@@ -109,11 +213,16 @@ export async function loadGatewayStartupConfigSnapshot(params: {

109213

assertValidGatewayStartupConfigSnapshot(configSnapshot, { includeDoctorHint: true });

110214

}

111215112-

const autoEnable = params.minimalTestGateway

113-

? { config: configSnapshot.config, changes: [] as string[] }

114-

: applyPluginAutoEnable({ config: configSnapshot.config, env: process.env });

216+

const autoEnable =

217+

params.minimalTestGateway || degradedStartupConfig

218+

? { config: configSnapshot.config, changes: [] as string[] }

219+

: applyPluginAutoEnable({ config: configSnapshot.config, env: process.env });

115220

if (autoEnable.changes.length === 0) {

116-

return { snapshot: configSnapshot, wroteConfig };

221+

return {

222+

snapshot: configSnapshot,

223+

wroteConfig,

224+

...(degradedStartupConfig ? { degradedProviderApi: true } : {}),

225+

};

117226

}

118227119228

try {

@@ -128,7 +237,11 @@ export async function loadGatewayStartupConfigSnapshot(params: {

128237

params.log.warn(`gateway: failed to persist plugin auto-enable changes: ${String(err)}`);

129238

}

130239131-

return { snapshot: configSnapshot, wroteConfig };

240+

return {

241+

snapshot: configSnapshot,

242+

wroteConfig,

243+

...(degradedStartupConfig ? { degradedProviderApi: true } : {}),

244+

};

132245

}

133246134247

export function createRuntimeSecretsActivator(params: {

@@ -226,6 +339,7 @@ export async function prepareGatewayStartupConfig(params: {

226339

authOverride?: GatewayAuthConfig;

227340

tailscaleOverride?: GatewayTailscaleConfig;

228341

activateRuntimeSecrets: ActivateRuntimeSecrets;

342+

persistStartupAuth?: boolean;

229343

}): Promise<Awaited<ReturnType<typeof ensureGatewayStartupAuth>>> {

230344

assertValidGatewayStartupConfigSnapshot(params.configSnapshot);

231345

@@ -262,7 +376,7 @@ export async function prepareGatewayStartupConfig(params: {

262376

env: process.env,

263377

authOverride: preflightAuthOverride,

264378

tailscaleOverride: params.tailscaleOverride,

265-

persist: true,

379+

persist: params.persistStartupAuth ?? true,

266380

baseHash: params.configSnapshot.hash,

267381

});

268382

const runtimeStartupConfig = applyGatewayAuthOverridesForStartupPreflight(authBootstrap.cfg, {