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

推荐订阅源

WordPress大学
WordPress大学
H
Help Net Security
Jina AI
Jina AI
V
V2EX
G
Google Developers Blog
B
Blog
GbyAI
GbyAI
U
Unit 42
爱范儿
爱范儿
腾讯CDC
Engineering at Meta
Engineering at Meta
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 三生石上(FineUI控件)
宝玉的分享
宝玉的分享
小众软件
小众软件
D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - Franky
博客园 - 聂微东
The Cloudflare Blog
I
InfoQ
Microsoft Azure Blog
Microsoft Azure Blog
Hugging Face - Blog
Hugging Face - 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: cancel stale provider auth prewarms (#85503) · openc...
steipete · 2026-05-23 · via Recent Commits to openclaw:main

@@ -8,7 +8,23 @@ const modelCatalogMocks = vi.hoisted(() => ({

8899

const modelAuthMocks = vi.hoisted(() => ({

1010

hasRuntimeAvailableProviderAuth:

11-

vi.fn<(params: { provider: string; cfg?: OpenClawConfig; workspaceDir?: string }) => boolean>(),

11+

vi.fn<

12+

(params: {

13+

provider: string;

14+

cfg?: OpenClawConfig;

15+

workspaceDir?: string;

16+

envAuthLookup?: unknown;

17+

}) => boolean

18+

>(),

19+

}));

20+21+

const providerAuthAliasMocks = vi.hoisted(() => ({

22+

resolveProviderAuthAliasMap: vi.fn(() => ({ openai: "openai" })),

23+

}));

24+25+

const modelAuthEnvVarMocks = vi.hoisted(() => ({

26+

resolveProviderEnvApiKeyCandidates: vi.fn(() => ({ openai: ["OPENAI_API_KEY"] })),

27+

resolveProviderEnvAuthEvidence: vi.fn(() => ({})),

1228

}));

13291430

const authProfilesMocks = vi.hoisted(() => ({

@@ -27,6 +43,15 @@ vi.mock("./model-auth.js", () => ({

2743

hasRuntimeAvailableProviderAuth: modelAuthMocks.hasRuntimeAvailableProviderAuth,

2844

}));

294546+

vi.mock("./provider-auth-aliases.js", () => ({

47+

resolveProviderAuthAliasMap: providerAuthAliasMocks.resolveProviderAuthAliasMap,

48+

}));

49+50+

vi.mock("./model-auth-env-vars.js", () => ({

51+

resolveProviderEnvApiKeyCandidates: modelAuthEnvVarMocks.resolveProviderEnvApiKeyCandidates,

52+

resolveProviderEnvAuthEvidence: modelAuthEnvVarMocks.resolveProviderEnvAuthEvidence,

53+

}));

54+3055

vi.mock("./auth-profiles.js", () => ({

3156

ensureAuthProfileStore: authProfilesMocks.ensureAuthProfileStore,

3257

ensureAuthProfileStoreWithoutExternalProfiles:

@@ -56,6 +81,26 @@ describe("prepared provider auth state", () => {

5681

vi.clearAllMocks();

5782

});

588384+

it("reuses prepared env auth lookup data while warming providers", async () => {

85+

const cfg = {} as OpenClawConfig;

86+

modelCatalogMocks.loadModelCatalog.mockResolvedValue([

87+

{ id: "gpt", name: "gpt", provider: "openai" },

88+

{ id: "claude", name: "claude", provider: "anthropic" },

89+

]);

90+

modelAuthMocks.hasRuntimeAvailableProviderAuth.mockReturnValue(false);

91+92+

await warmCurrentProviderAuthState(cfg);

93+94+

expect(providerAuthAliasMocks.resolveProviderAuthAliasMap).toHaveBeenCalledTimes(1);

95+

expect(modelAuthEnvVarMocks.resolveProviderEnvApiKeyCandidates).toHaveBeenCalledTimes(1);

96+

expect(modelAuthEnvVarMocks.resolveProviderEnvAuthEvidence).toHaveBeenCalledTimes(1);

97+

const firstLookup =

98+

modelAuthMocks.hasRuntimeAvailableProviderAuth.mock.calls[0]?.[0].envAuthLookup;

99+

const secondLookup =

100+

modelAuthMocks.hasRuntimeAvailableProviderAuth.mock.calls[1]?.[0].envAuthLookup;

101+

expect(firstLookup).toBe(secondLookup);

102+

});

103+59104

it("hasAuthForModelProvider returns the prepared answer after warm and falls through to compute after clear", async () => {

60105

const cfg = {} as OpenClawConfig;

61106

modelCatalogMocks.loadModelCatalog.mockResolvedValue([

@@ -192,17 +237,17 @@ describe("prepared provider auth state", () => {

192237

await secondWarm;

193238

resolveFirstCatalog?.([{ id: "gpt", name: "gpt", provider: "openai" }]);

194239

await firstWarm;

195-

expect(modelAuthMocks.hasRuntimeAvailableProviderAuth).toHaveBeenCalledTimes(2);

240+

expect(modelAuthMocks.hasRuntimeAvailableProviderAuth).toHaveBeenCalledTimes(1);

196241197242

modelAuthMocks.hasRuntimeAvailableProviderAuth.mockReturnValue(true);

198243

await expect(hasAuthForModelProvider({ provider: "openai", cfg: secondCfg })).resolves.toBe(

199244

false,

200245

);

201-

expect(modelAuthMocks.hasRuntimeAvailableProviderAuth).toHaveBeenCalledTimes(2);

246+

expect(modelAuthMocks.hasRuntimeAvailableProviderAuth).toHaveBeenCalledTimes(1);

202247

await expect(hasAuthForModelProvider({ provider: "openai", cfg: firstCfg })).resolves.toBe(

203248

true,

204249

);

205-

expect(modelAuthMocks.hasRuntimeAvailableProviderAuth).toHaveBeenCalledTimes(3);

250+

expect(modelAuthMocks.hasRuntimeAvailableProviderAuth).toHaveBeenCalledTimes(2);

206251

});

207252208253

it("does not publish a warm that is cancelled before completion", async () => {

@@ -224,6 +269,28 @@ describe("prepared provider auth state", () => {

224269225270

modelAuthMocks.hasRuntimeAvailableProviderAuth.mockReturnValue(false);

226271

await expect(hasAuthForModelProvider({ provider: "openai", cfg })).resolves.toBe(false);

227-

expect(modelAuthMocks.hasRuntimeAvailableProviderAuth).toHaveBeenCalledTimes(2);

272+

expect(modelAuthMocks.hasRuntimeAvailableProviderAuth).toHaveBeenCalledTimes(1);

273+

});

274+275+

it("stops sweeping providers when a warm is cancelled mid-flight", async () => {

276+

const cfg = {} as OpenClawConfig;

277+

let cancelled = false;

278+

modelCatalogMocks.loadModelCatalog.mockResolvedValue([

279+

{ id: "gpt", name: "gpt", provider: "openai" },

280+

{ id: "claude", name: "claude", provider: "anthropic" },

281+

{ id: "gemini", name: "gemini", provider: "google" },

282+

]);

283+

modelAuthMocks.hasRuntimeAvailableProviderAuth.mockImplementation(() => {

284+

cancelled = true;

285+

return false;

286+

});

287+288+

await warmCurrentProviderAuthState(cfg, { isCancelled: () => cancelled });

289+

expect(modelAuthMocks.hasRuntimeAvailableProviderAuth).toHaveBeenCalledTimes(1);

290+291+

modelAuthMocks.hasRuntimeAvailableProviderAuth.mockClear();

292+

modelAuthMocks.hasRuntimeAvailableProviderAuth.mockReturnValue(true);

293+

await expect(hasAuthForModelProvider({ provider: "openai", cfg })).resolves.toBe(true);

294+

expect(modelAuthMocks.hasRuntimeAvailableProviderAuth).toHaveBeenCalledTimes(1);

228295

});

229296

});