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

推荐订阅源

Martin Fowler
Martin Fowler
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
博客园_首页
宝玉的分享
宝玉的分享
S
SegmentFault 最新的问题
Jina AI
Jina AI
Hugging Face - Blog
Hugging Face - Blog
V
Visual Studio Blog
美团技术团队
IT之家
IT之家
罗磊的独立博客
Blog — PlanetScale
Blog — PlanetScale
Google DeepMind News
Google DeepMind News
月光博客
月光博客
Microsoft Azure Blog
Microsoft Azure Blog
H
Help Net Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Last Week in AI
Last Week in AI
博客园 - 叶小钗
M
MIT News - Artificial intelligence
B
Blog RSS Feed
有赞技术团队
有赞技术团队
Y
Y Combinator 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(gateway): keep models list read-only fast · openclaw/...
vincentkoc · 2026-05-03 · via Recent Commits to openclaw:main

@@ -69,6 +69,18 @@ function mockSingleOpenAiCatalogModel() {

6969

mockPiDiscoveryModels([{ id: "gpt-4.1", provider: "openai", name: "GPT-4.1" }]);

7070

}

717172+

function emptyPluginMetadataSnapshot() {

73+

return {

74+

policyHash: "test-policy",

75+

configFingerprint: "test-config",

76+

index: {

77+

policyHash: "test-policy",

78+

plugins: [],

79+

},

80+

plugins: [],

81+

};

82+

}

83+7284

describe("loadModelCatalog", () => {

7385

beforeAll(async () => {

7486

readFileMock = vi.fn();

@@ -117,7 +129,9 @@ describe("loadModelCatalog", () => {

117129

ensureOpenClawModelsJsonMock.mockClear();

118130

augmentCatalogMock.mockClear();

119131

currentPluginMetadataSnapshotMock.mockReset();

132+

currentPluginMetadataSnapshotMock.mockReturnValue(emptyPluginMetadataSnapshot());

120133

loadPluginMetadataSnapshotMock.mockReset();

134+

loadPluginMetadataSnapshotMock.mockReturnValue(emptyPluginMetadataSnapshot());

121135

});

122136123137

afterEach(() => {

@@ -206,26 +220,46 @@ describe("loadModelCatalog", () => {

206220

}

207221

});

208222209-

it("does not prepare models.json when loading catalog in read-only mode", async () => {

210-

const discoverAuthStorage = vi.fn(() => ({}));

211-

__setModelCatalogImportForTest(

212-

async () =>

213-

({

214-

discoverAuthStorage,

215-

AuthStorage: function AuthStorage() {},

216-

ModelRegistry: class {

217-

getAll() {

218-

return [{ id: "gpt-4.1", name: "GPT-4.1", provider: "openai" }];

219-

}

220-

},

221-

}) as unknown as PiSdkModule,

222-

);

223+

it("does not prepare models.json or import provider discovery when loading fallback catalog in read-only mode", async () => {

224+

const importPiSdk = vi.fn(async () => {

225+

throw new Error("provider discovery should not load");

226+

});

227+

__setModelCatalogImportForTest(importPiSdk as unknown as () => Promise<PiSdkModule>);

228+

currentPluginMetadataSnapshotMock.mockReturnValueOnce(undefined);

229+

loadPluginMetadataSnapshotMock.mockImplementationOnce(() => {

230+

throw new Error("metadata scan should not run");

231+

});

223232224-

const result = await loadModelCatalog({ config: {} as OpenClawConfig, readOnly: true });

233+

const result = await loadModelCatalog({

234+

config: {

235+

models: {

236+

providers: {

237+

openai: {

238+

baseUrl: "https://openai.example.com/v1",

239+

models: [

240+

{

241+

id: "gpt-test",

242+

name: "GPT Test",

243+

reasoning: false,

244+

input: ["text"],

245+

cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },

246+

contextWindow: 200_000,

247+

maxTokens: 8192,

248+

},

249+

],

250+

},

251+

},

252+

},

253+

} as OpenClawConfig,

254+

readOnly: true,

255+

});

225256226-

expect(result).toEqual([{ id: "gpt-4.1", name: "GPT-4.1", provider: "openai" }]);

257+

expect(result).toContainEqual(

258+

expect.objectContaining({ id: "gpt-test", name: "GPT Test", provider: "openai" }),

259+

);

227260

expect(ensureOpenClawModelsJsonMock).not.toHaveBeenCalled();

228-

expect(discoverAuthStorage).toHaveBeenCalledWith("/tmp/openclaw", { readOnly: true });

261+

expect(importPiSdk).not.toHaveBeenCalled();

262+

expect(loadPluginMetadataSnapshotMock).not.toHaveBeenCalled();

229263

});

230264231265

it("filters suppressed built-ins from persisted read-only catalog rows", async () => {

@@ -279,7 +313,7 @@ describe("loadModelCatalog", () => {

279313

expect(augmentCatalogMock).not.toHaveBeenCalled();

280314

});

281315282-

it("falls back to the registry when persisted read-only catalog has no model rows", async () => {

316+

it("falls back to manifest catalog rows when persisted read-only catalog has no model rows", async () => {

283317

readFileMock.mockResolvedValueOnce(

284318

JSON.stringify({

285319

providers: {

@@ -293,27 +327,50 @@ describe("loadModelCatalog", () => {

293327

},

294328

}),

295329

);

296-

const discoverAuthStorage = vi.fn(() => ({

297-

getOAuthProviders: () => [],

298-

}));

299-

__setModelCatalogImportForTest(

300-

async () =>

301-

({

302-

discoverAuthStorage,

303-

AuthStorage: function AuthStorage() {},

304-

ModelRegistry: class {

305-

getAll() {

306-

return [{ id: "gpt-4.1", name: "GPT-4.1", provider: "openai" }];

307-

}

330+

currentPluginMetadataSnapshotMock.mockReturnValueOnce({

331+

policyHash: "policy",

332+

index: {

333+

policyHash: "policy",

334+

plugins: [

335+

{

336+

pluginId: "external-provider",

337+

enabled: true,

338+

origin: "global",

308339

},

309-

}) as unknown as PiSdkModule,

310-

);

340+

],

341+

},

342+

plugins: [

343+

{

344+

id: "external-provider",

345+

origin: "global",

346+

modelCatalog: {

347+

providers: {

348+

external: {

349+

models: [{ id: "external-fast", name: "External Fast" }],

350+

},

351+

},

352+

},

353+

},

354+

],

355+

});

356+

const importPiSdk = vi.fn(async () => {

357+

throw new Error("provider discovery should not load");

358+

});

359+

__setModelCatalogImportForTest(importPiSdk as unknown as () => Promise<PiSdkModule>);

311360312361

const result = await loadModelCatalog({ config: {} as OpenClawConfig, readOnly: true });

313362314-

expect(result).toEqual([{ id: "gpt-4.1", name: "GPT-4.1", provider: "openai" }]);

363+

expect(result).toEqual([

364+

{

365+

provider: "external",

366+

id: "external-fast",

367+

name: "External Fast",

368+

input: ["text"],

369+

reasoning: false,

370+

},

371+

]);

315372

expect(ensureOpenClawModelsJsonMock).not.toHaveBeenCalled();

316-

expect(discoverAuthStorage).toHaveBeenCalledWith("/tmp/openclaw", { readOnly: true });

373+

expect(importPiSdk).not.toHaveBeenCalled();

317374

});

318375319376

it("preserves registry defaults for minimal persisted read-only catalog rows", async () => {