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

推荐订阅源

宝玉的分享
宝玉的分享
Engineering at Meta
Engineering at Meta
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 聂微东
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Last Week in AI
Last Week in AI
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 三生石上(FineUI控件)
T
Tailwind CSS Blog
Apple Machine Learning Research
Apple Machine Learning Research
Hugging Face - Blog
Hugging Face - Blog
爱范儿
爱范儿
博客园 - 司徒正美
人人都是产品经理
人人都是产品经理
Jina AI
Jina AI
博客园 - 叶小钗
雷峰网
雷峰网
罗磊的独立博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - Franky
WordPress大学
WordPress大学
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
阮一峰的网络日志
阮一峰的网络日志
量子位

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(cron): skip isolated runs when local providers are do...
steipete · 2026-04-28 · via Recent Commits to openclaw:main

@@ -0,0 +1,163 @@

1+

import { beforeEach, describe, expect, it, vi } from "vitest";

2+3+

const { fetchWithSsrFGuardMock } = vi.hoisted(() => ({

4+

fetchWithSsrFGuardMock: vi.fn(),

5+

}));

6+7+

vi.mock("../../infra/net/fetch-guard.js", () => ({

8+

fetchWithSsrFGuard: fetchWithSsrFGuardMock,

9+

}));

10+11+

import {

12+

preflightCronModelProvider,

13+

resetCronModelProviderPreflightCacheForTest,

14+

} from "./model-preflight.runtime.js";

15+16+

function mockReachableResponse(status = 200) {

17+

fetchWithSsrFGuardMock.mockResolvedValueOnce({

18+

response: { status },

19+

release: vi.fn(async () => {}),

20+

});

21+

}

22+23+

describe("preflightCronModelProvider", () => {

24+

beforeEach(() => {

25+

fetchWithSsrFGuardMock.mockReset();

26+

resetCronModelProviderPreflightCacheForTest();

27+

});

28+29+

it("skips network checks for cloud provider URLs", async () => {

30+

const result = await preflightCronModelProvider({

31+

cfg: {

32+

models: {

33+

providers: {

34+

openai: {

35+

api: "openai-responses",

36+

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

37+

models: [],

38+

},

39+

},

40+

},

41+

},

42+

provider: "openai",

43+

model: "gpt-5.4",

44+

});

45+46+

expect(result).toEqual({ status: "available" });

47+

expect(fetchWithSsrFGuardMock).not.toHaveBeenCalled();

48+

});

49+50+

it("treats any HTTP response from a local OpenAI-compatible endpoint as reachable", async () => {

51+

mockReachableResponse(401);

52+53+

const result = await preflightCronModelProvider({

54+

cfg: {

55+

models: {

56+

providers: {

57+

vllm: {

58+

api: "openai-completions",

59+

baseUrl: "http://127.0.0.1:8000/v1",

60+

models: [],

61+

},

62+

},

63+

},

64+

},

65+

provider: "vllm",

66+

model: "llama",

67+

});

68+69+

expect(result).toEqual({ status: "available" });

70+

expect(fetchWithSsrFGuardMock).toHaveBeenCalledWith(

71+

expect.objectContaining({

72+

url: "http://127.0.0.1:8000/v1/models",

73+

timeoutMs: 2500,

74+

}),

75+

);

76+

});

77+78+

it("marks unreachable local Ollama endpoints unavailable and caches the result", async () => {

79+

fetchWithSsrFGuardMock.mockRejectedValueOnce(new Error("ECONNREFUSED"));

80+81+

const cfg = {

82+

models: {

83+

providers: {

84+

Ollama: {

85+

api: "ollama" as const,

86+

baseUrl: "http://localhost:11434",

87+

models: [],

88+

},

89+

},

90+

},

91+

};

92+

const first = await preflightCronModelProvider({

93+

cfg,

94+

provider: "ollama",

95+

model: "qwen3:32b",

96+

nowMs: 1000,

97+

});

98+

const second = await preflightCronModelProvider({

99+

cfg,

100+

provider: "ollama",

101+

model: "llama3.3:70b",

102+

nowMs: 2000,

103+

});

104+105+

expect(first).toMatchObject({

106+

status: "unavailable",

107+

provider: "ollama",

108+

model: "qwen3:32b",

109+

baseUrl: "http://localhost:11434",

110+

retryAfterMs: 300000,

111+

});

112+

expect(second).toMatchObject({

113+

status: "unavailable",

114+

provider: "ollama",

115+

model: "llama3.3:70b",

116+

baseUrl: "http://localhost:11434",

117+

retryAfterMs: 300000,

118+

});

119+

expect(fetchWithSsrFGuardMock).toHaveBeenCalledTimes(1);

120+

expect(fetchWithSsrFGuardMock).toHaveBeenCalledWith(

121+

expect.objectContaining({

122+

url: "http://localhost:11434/api/tags",

123+

auditContext: "cron-model-provider-preflight",

124+

}),

125+

);

126+

});

127+128+

it("retries an unavailable endpoint after the cache ttl", async () => {

129+

fetchWithSsrFGuardMock.mockRejectedValueOnce(new Error("ECONNREFUSED")).mockResolvedValueOnce({

130+

response: { status: 200 },

131+

release: vi.fn(async () => {}),

132+

});

133+134+

const cfg = {

135+

models: {

136+

providers: {

137+

ollama: {

138+

api: "ollama" as const,

139+

baseUrl: "http://127.0.0.1:11434",

140+

models: [],

141+

},

142+

},

143+

},

144+

};

145+146+

const first = await preflightCronModelProvider({

147+

cfg,

148+

provider: "ollama",

149+

model: "llama3",

150+

nowMs: 1000,

151+

});

152+

const second = await preflightCronModelProvider({

153+

cfg,

154+

provider: "ollama",

155+

model: "llama3",

156+

nowMs: 1000 + 300001,

157+

});

158+159+

expect(first.status).toBe("unavailable");

160+

expect(second).toEqual({ status: "available" });

161+

expect(fetchWithSsrFGuardMock).toHaveBeenCalledTimes(2);

162+

});

163+

});