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

推荐订阅源

M
MIT News - Artificial intelligence
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
Apple Machine Learning Research
Apple Machine Learning Research
Last Week in AI
Last Week in AI
S
SegmentFault 最新的问题
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
美团技术团队
人人都是产品经理
人人都是产品经理
WordPress大学
WordPress大学
The Cloudflare Blog
IT之家
IT之家
雷峰网
雷峰网
小众软件
小众软件
博客园 - 叶小钗
博客园 - 聂微东
爱范儿
爱范儿
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
V
Visual Studio Blog
博客园 - 【当耐特】
V
V2EX
博客园_首页
T
Tailwind CSS 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(agents): cache fallback provider resolution · opencla...
vincentkoc · 2026-05-25 · via Recent Commits to openclaw:main

@@ -6,9 +6,13 @@ import { resetLogger, setLoggerOverride } from "../logging/logger.js";

66

import { createWarnLogCapture } from "../logging/test-helpers/warn-log-capture.js";

77

import {

88

clearCurrentPluginMetadataSnapshot,

9+

resolvePluginMetadataControlPlaneFingerprint,

910

setCurrentPluginMetadataSnapshot,

1011

} from "../plugins/current-plugin-metadata-snapshot.js";

12+

import { resolveInstalledPluginIndexPolicyHash } from "../plugins/installed-plugin-index-policy.js";

13+

import type { InstalledPluginIndex } from "../plugins/installed-plugin-index.js";

1114

import { loadPluginMetadataSnapshot } from "../plugins/plugin-metadata-snapshot.js";

15+

import type { PluginMetadataSnapshot } from "../plugins/plugin-metadata-snapshot.types.js";

1216

import { CommandLaneTaskTimeoutError } from "../process/command-queue.js";

1317

import { AUTH_STORE_VERSION } from "./auth-profiles/constants.js";

1418

import type { AuthProfileStore } from "./auth-profiles/types.js";

@@ -164,10 +168,7 @@ let authTempRoot = "";

164168

let authTempCounter = 0;

165169166170

beforeAll(() => {

167-

setCurrentPluginMetadataSnapshot(loadPluginMetadataSnapshot({ config: {}, env: process.env }), {

168-

config: {},

169-

env: process.env,

170-

});

171+

setDefaultPluginMetadataSnapshot();

171172

});

172173173174

afterAll(() => {

@@ -181,6 +182,73 @@ function resetModelFallbackTestState(): void {

181182

authSourceCheckMock.hasAnyAuthProfileStoreSource.mockReset().mockReturnValue(false);

182183

}

183184185+

function setDefaultPluginMetadataSnapshot(): void {

186+

setCurrentPluginMetadataSnapshot(loadPluginMetadataSnapshot({ config: {}, env: process.env }), {

187+

config: {},

188+

env: process.env,

189+

});

190+

}

191+192+

function createModelNormalizerSnapshot(params: {

193+

manifestHash: string;

194+

prefix: string;

195+

}): PluginMetadataSnapshot {

196+

const policyHash = resolveInstalledPluginIndexPolicyHash({});

197+

const index: InstalledPluginIndex = {

198+

version: 1,

199+

hostContractVersion: "test-host",

200+

compatRegistryVersion: "test-compat",

201+

migrationVersion: 1,

202+

policyHash,

203+

generatedAtMs: 0,

204+

installRecords: {},

205+

plugins: [

206+

{

207+

pluginId: "fallback-normalizer",

208+

manifestPath: `/tmp/fallback-normalizer-${params.manifestHash}/openclaw.plugin.json`,

209+

manifestHash: params.manifestHash,

210+

source: `/tmp/fallback-normalizer-${params.manifestHash}/index.ts`,

211+

rootDir: `/tmp/fallback-normalizer-${params.manifestHash}`,

212+

origin: "global",

213+

enabled: true,

214+

startup: {

215+

sidecar: false,

216+

memory: false,

217+

deferConfiguredChannelFullLoadUntilAfterListen: false,

218+

agentHarnesses: [],

219+

},

220+

compat: [],

221+

},

222+

],

223+

diagnostics: [],

224+

};

225+

return {

226+

policyHash,

227+

configFingerprint: resolvePluginMetadataControlPlaneFingerprint(

228+

{},

229+

{

230+

env: process.env,

231+

index,

232+

policyHash,

233+

},

234+

),

235+

index,

236+

registryDiagnostics: [],

237+

plugins: [

238+

{

239+

id: "fallback-normalizer",

240+

modelIdNormalization: {

241+

providers: {

242+

demo: {

243+

prefixWhenBare: params.prefix,

244+

},

245+

},

246+

},

247+

},

248+

],

249+

} as unknown as PluginMetadataSnapshot;

250+

}

251+184252

afterEach(resetModelFallbackTestState);

185253186254

beforeEach(() => {

@@ -227,6 +295,31 @@ function makeProviderFallbackCfg(provider: string): OpenClawConfig {

227295

});

228296

}

229297298+

function makeProviderOrderFallbackCfg(

299+

entries: Array<[provider: string, model: string]>,

300+

): OpenClawConfig {

301+

return {

302+

agents: {

303+

defaults: {

304+

model: {

305+

fallbacks: [],

306+

},

307+

},

308+

},

309+

models: {

310+

providers: Object.fromEntries(

311+

entries.map(([provider, model]) => [

312+

provider,

313+

{

314+

baseUrl: `https://${provider}.example.test`,

315+

models: [{ id: model }],

316+

},

317+

]),

318+

),

319+

},

320+

} as unknown as OpenClawConfig;

321+

}

322+230323

async function withTempAuthStore<T>(

231324

store: AuthProfileStore,

232325

run: (tempDir: string) => Promise<T>,

@@ -1969,6 +2062,82 @@ describe("runWithModelFallback", () => {

19692062

]);

19702063

});

197120642065+

it("does not reuse provider-order-sensitive configured fallback candidates", () => {

2066+

const anthropicFirst = makeProviderOrderFallbackCfg([

2067+

["anthropic", "claude-sonnet-4"],

2068+

["ollama", "llama3"],

2069+

]);

2070+

const ollamaFirst = makeProviderOrderFallbackCfg([

2071+

["ollama", "llama3"],

2072+

["anthropic", "claude-sonnet-4"],

2073+

]);

2074+2075+

expect(

2076+

testing.resolveFallbackCandidates({

2077+

cfg: anthropicFirst,

2078+

provider: "",

2079+

model: "",

2080+

fallbacksOverride: [],

2081+

}),

2082+

).toEqual([{ provider: "anthropic", model: "claude-sonnet-4" }]);

2083+

expect(

2084+

testing.resolveFallbackCandidates({

2085+

cfg: ollamaFirst,

2086+

provider: "",

2087+

model: "",

2088+

fallbacksOverride: [],

2089+

}),

2090+

).toEqual([{ provider: "ollama", model: "llama3" }]);

2091+

});

2092+2093+

it("does not reuse fallback candidate cache entries across manifest normalization snapshots", () => {

2094+

const cfg = makeCfg({

2095+

agents: {

2096+

defaults: {

2097+

model: {

2098+

fallbacks: [],

2099+

},

2100+

},

2101+

},

2102+

});

2103+2104+

try {

2105+

setCurrentPluginMetadataSnapshot(

2106+

createModelNormalizerSnapshot({

2107+

manifestHash: "alpha",

2108+

prefix: "alpha",

2109+

}),

2110+

{ config: {}, env: process.env },

2111+

);

2112+

expect(

2113+

testing.resolveFallbackCandidates({

2114+

cfg,

2115+

provider: "demo",

2116+

model: "demo-model",

2117+

fallbacksOverride: [],

2118+

}),

2119+

).toEqual([{ provider: "demo", model: "alpha/demo-model" }]);

2120+2121+

setCurrentPluginMetadataSnapshot(

2122+

createModelNormalizerSnapshot({

2123+

manifestHash: "bravo",

2124+

prefix: "bravo",

2125+

}),

2126+

{ config: {}, env: process.env },

2127+

);

2128+

expect(

2129+

testing.resolveFallbackCandidates({

2130+

cfg,

2131+

provider: "demo",

2132+

model: "demo-model",

2133+

fallbacksOverride: [],

2134+

}),

2135+

).toEqual([{ provider: "demo", model: "bravo/demo-model" }]);

2136+

} finally {

2137+

setDefaultPluginMetadataSnapshot();

2138+

}

2139+

});

2140+19722141

it("defaults provider/model when missing (regression #946)", () => {

19732142

const cfg = makeCfg({

19742143

agents: {