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

推荐订阅源

L
LangChain Blog
S
SegmentFault 最新的问题
V
Visual Studio Blog
J
Java Code Geeks
宝玉的分享
宝玉的分享
美团技术团队
博客园 - Franky
酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hackread – Cybersecurity News, Data Breaches, AI and More
有赞技术团队
有赞技术团队
量子位
Martin Fowler
Martin Fowler
MyScale Blog
MyScale Blog
Google DeepMind News
Google DeepMind News
Jina AI
Jina AI
博客园 - 叶小钗
月光博客
月光博客
P
Proofpoint News Feed
D
DataBreaches.Net
Blog — PlanetScale
Blog — PlanetScale
博客园_首页
腾讯CDC
Microsoft Azure Blog
Microsoft Azure Blog
Stack Overflow Blog
Stack Overflow 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
test(agents): cover fallback attempt position · openclaw/...
vincentkoc · 2026-06-22 · via Recent Commits to openclaw:main

@@ -446,7 +446,11 @@ async function expectFallsBackToHaiku(params: {

446446447447

expect(result.result).toBe("ok");

448448

expect(run).toHaveBeenCalledTimes(2);

449-

expect(requireMockCall(run, 1, "fallback run")).toEqual(["anthropic", "claude-haiku-3-5"]);

449+

expect(requireMockCall(run, 1, "fallback run")).toEqual([

450+

"anthropic",

451+

"claude-haiku-3-5",

452+

{ isFinalFallbackAttempt: true },

453+

]);

450454

}

451455452456

function createOverrideFailureRun(params: {

@@ -540,7 +544,7 @@ async function expectSkippedUnavailableProvider(params: {

540544

});

541545542546

expect(result.result).toBe("ok");

543-

expect(run.mock.calls).toEqual([["fallback", "ok-model"]]);

547+

expect(run.mock.calls).toEqual([["fallback", "ok-model", { isFinalFallbackAttempt: true }]]);

544548

expect(result.attempts[0]?.reason).toBe(params.expectedReason);

545549

expect(result.attempts[0]?.authMode).toBe(params.expectedAuthMode);

546550

}

@@ -637,7 +641,9 @@ describe("runWithModelFallback", () => {

637641

"/tmp/openclaw-no-auth-profiles",

638642

);

639643

expect(authRuntimeMock.runtime.ensureAuthProfileStore).not.toHaveBeenCalled();

640-

expect(run).toHaveBeenCalledWith("openai", "gpt-4.1-mini");

644+

expect(run).toHaveBeenCalledWith("openai", "gpt-4.1-mini", {

645+

isFinalFallbackAttempt: false,

646+

});

641647

});

642648643649

it("resolves primary model aliases before running", () => {

@@ -759,7 +765,11 @@ describe("runWithModelFallback", () => {

759765

});

760766

expect(result.result).toBe("ok");

761767

expect(run).toHaveBeenCalledTimes(2);

762-

expect(requireMockCall(run, 1, "fallback run")).toEqual(["anthropic", "claude-haiku-3-5"]);

768+

expect(requireMockCall(run, 1, "fallback run")).toEqual([

769+

"anthropic",

770+

"claude-haiku-3-5",

771+

{ isFinalFallbackAttempt: false },

772+

]);

763773

expect(result.attempts).toHaveLength(1);

764774

expect(result.attempts[0].reason).toBe("overloaded");

765775

});

@@ -1070,7 +1080,11 @@ describe("runWithModelFallback", () => {

1070108010711081

expect(result.result).toBe("external cli ok");

10721082

expect(run).toHaveBeenCalledTimes(1);

1073-

expect(run.mock.calls[0]).toEqual(["anthropic", "claude-sonnet-4-6"]);

1083+

expect(run.mock.calls[0]).toEqual([

1084+

"anthropic",

1085+

"claude-sonnet-4-6",

1086+

{ isFinalFallbackAttempt: false },

1087+

]);

10741088

expect(result.attempts).toStrictEqual([]);

10751089

});

10761090

@@ -1114,7 +1128,11 @@ describe("runWithModelFallback", () => {

1114112811151129

expect(result.result).toBe("cli ok");

11161130

expect(run).toHaveBeenCalledTimes(1);

1117-

expect(run.mock.calls[0]).toEqual(["anthropic", "claude-sonnet-4-6"]);

1131+

expect(run.mock.calls[0]).toEqual([

1132+

"anthropic",

1133+

"claude-sonnet-4-6",

1134+

{ isFinalFallbackAttempt: true },

1135+

]);

11181136

expect(result.attempts).toStrictEqual([]);

11191137

});

11201138

@@ -1162,7 +1180,7 @@ describe("runWithModelFallback", () => {

1162118011631181

expect(result.result).toBe("direct cli ok");

11641182

expect(run).toHaveBeenCalledTimes(1);

1165-

expect(run.mock.calls[0]).toEqual(["claude-cli", "opus"]);

1183+

expect(run.mock.calls[0]).toEqual(["claude-cli", "opus", { isFinalFallbackAttempt: true }]);

11661184

expect(result.attempts).toStrictEqual([]);

11671185

});

11681186

@@ -1467,7 +1485,11 @@ describe("runWithModelFallback", () => {

1467148514681486

expect(result.result).toEqual({ payloads: [{ text: "fallback ok" }] });

14691487

expect(run).toHaveBeenCalledTimes(2);

1470-

expect(requireMockCall(run, 1, "fallback run")).toEqual(["anthropic", "claude-haiku-3-5"]);

1488+

expect(requireMockCall(run, 1, "fallback run")).toEqual([

1489+

"anthropic",

1490+

"claude-haiku-3-5",

1491+

{ isFinalFallbackAttempt: true },

1492+

]);

14711493

expect(result.attempts[0]?.provider).toBe("openai");

14721494

expect(result.attempts[0]?.model).toBe("gpt-5.4");

14731495

expect(result.attempts[0]?.reason).toBe("format");

@@ -1513,7 +1535,11 @@ describe("runWithModelFallback", () => {

1513153515141536

expect(result.result.payloads).toEqual([{ text: "fallback ok" }]);

15151537

expect(run).toHaveBeenCalledTimes(2);

1516-

expect(requireMockCall(run, 1, "fallback run")).toEqual(["openai", "gpt-5.5"]);

1538+

expect(requireMockCall(run, 1, "fallback run")).toEqual([

1539+

"openai",

1540+

"gpt-5.5",

1541+

{ isFinalFallbackAttempt: true },

1542+

]);

15171543

expect(result.attempts[0]).toMatchObject({

15181544

provider: "zai",

15191545

model: "glm-5.1",

@@ -1835,8 +1861,8 @@ describe("runWithModelFallback", () => {

18351861

expect(result.attempts).toStrictEqual([]);

18361862

expect(onError).not.toHaveBeenCalled();

18371863

expect(run.mock.calls).toEqual([

1838-

["openai", "gpt-4.1-mini"],

1839-

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

1864+

["openai", "gpt-4.1-mini", { isFinalFallbackAttempt: false }],

1865+

["anthropic", "claude-sonnet-4-6", { isFinalFallbackAttempt: false }],

18401866

]);

18411867

});

18421868

@@ -1860,8 +1886,8 @@ describe("runWithModelFallback", () => {

18601886

expect(result.model).toBe("claude-haiku-3-5");

18611887

expect(result.attempts[0]?.reason).toBe("unknown");

18621888

expect(run.mock.calls).toEqual([

1863-

["openai", "gpt-4.1-mini"],

1864-

["anthropic", "claude-haiku-3-5"],

1889+

["openai", "gpt-4.1-mini", { isFinalFallbackAttempt: false }],

1890+

["anthropic", "claude-haiku-3-5", { isFinalFallbackAttempt: true }],

18651891

]);

18661892

});

18671893

@@ -2083,9 +2109,9 @@ describe("runWithModelFallback", () => {

2083210920842110

expect(result.result).toBe("ok");

20852111

expect(run.mock.calls).toEqual([

2086-

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

2087-

["anthropic", "claude-haiku-3-5"],

2088-

["openai", "gpt-4.1-mini"],

2112+

["anthropic", "claude-opus-4", { isFinalFallbackAttempt: false }],

2113+

["anthropic", "claude-haiku-3-5", { isFinalFallbackAttempt: false }],

2114+

["openai", "gpt-4.1-mini", { isFinalFallbackAttempt: true }],

20892115

]);

20902116

});

20912117

@@ -2162,8 +2188,8 @@ describe("runWithModelFallback", () => {

2162218821632189

expect(result.result).toBe("ok");

21642190

expect(run.mock.calls).toEqual([

2165-

["openrouter", "xiaomi/mimo-v2-pro"],

2166-

["openai", "gpt-4.1-mini"],

2191+

["openrouter", "xiaomi/mimo-v2-pro", { isFinalFallbackAttempt: false }],

2192+

["openai", "gpt-4.1-mini", { isFinalFallbackAttempt: true }],

21672193

]);

21682194

expect(result.attempts).toHaveLength(1);

21692195

expect(result.attempts[0]?.reason).toBe("billing");

@@ -2177,6 +2203,7 @@ describe("runWithModelFallback", () => {

21772203

error: Error;

21782204

expectedFallback: [string, string];

21792205

expectedReason?: string;

2206+

isFinalFallbackAttempt?: boolean;

21802207

}> = [

21812208

{

21822209

name: "unknown anthropic override",

@@ -2199,6 +2226,7 @@ describe("runWithModelFallback", () => {

21992226

error: new Error("stream_read_error"),

22002227

expectedFallback: ["anthropic", "claude-haiku-3-5"],

22012228

expectedReason: "timeout",

2229+

isFinalFallbackAttempt: true,

22022230

},

22032231

];

22042232

@@ -2216,7 +2244,10 @@ describe("runWithModelFallback", () => {

2216224422172245

expect(result.result).toBe("ok");

22182246

expect(run).toHaveBeenCalledTimes(2);

2219-

expect(requireMockCall(run, 1, "fallback run")).toEqual(testCase.expectedFallback);

2247+

expect(requireMockCall(run, 1, "fallback run")).toEqual([

2248+

...testCase.expectedFallback,

2249+

{ isFinalFallbackAttempt: testCase.isFinalFallbackAttempt ?? false },

2250+

]);

22202251

if (testCase.expectedReason) {

22212252

expect(result.attempts).toHaveLength(1);

22222253

expect(result.attempts[0]?.reason).toBe(testCase.expectedReason);

@@ -2376,7 +2407,7 @@ describe("runWithModelFallback", () => {

23762407

});

2377240823782409

expect(result.result).toBe("ok");

2379-

expect(run.mock.calls).toEqual([[provider, "m1"]]);

2410+

expect(run.mock.calls).toEqual([[provider, "m1", { isFinalFallbackAttempt: false }]]);

23802411

expect(result.attempts).toStrictEqual([]);

23812412

});

23822413

@@ -2987,6 +3018,7 @@ describe("runWithModelFallback", () => {

29873018

expect(run).toHaveBeenCalledTimes(1);

29883019

expect(run).toHaveBeenNthCalledWith(1, "anthropic", "claude-sonnet-4-5", {

29893020

allowTransientCooldownProbe: true,

3021+

isFinalFallbackAttempt: false,

29903022

});

29913023

});

29923024

@@ -3020,6 +3052,7 @@ describe("runWithModelFallback", () => {

30203052

expect(run).toHaveBeenCalledTimes(1);

30213053

expect(run).toHaveBeenNthCalledWith(1, "anthropic", "claude-sonnet-4-6", {

30223054

allowTransientCooldownProbe: true,

3055+

isFinalFallbackAttempt: false,

30233056

});

30243057

});

30253058

@@ -3048,7 +3081,9 @@ describe("runWithModelFallback", () => {

3048308130493082

expect(result.result).toBe("groq success");

30503083

expect(run).toHaveBeenCalledTimes(1);

3051-

expect(run).toHaveBeenNthCalledWith(1, "groq", "llama-3.3-70b-versatile");

3084+

expect(run).toHaveBeenNthCalledWith(1, "groq", "llama-3.3-70b-versatile", {

3085+

isFinalFallbackAttempt: true,

3086+

});

30523087

});

3053308830543089

it("tries cross-provider fallbacks when same provider has rate limit", async () => {

@@ -3096,8 +3131,11 @@ describe("runWithModelFallback", () => {

30963131

expect(run).toHaveBeenCalledTimes(2);

30973132

expect(run).toHaveBeenNthCalledWith(1, "anthropic", "claude-opus-4-6", {

30983133

allowTransientCooldownProbe: true,

3134+

isFinalFallbackAttempt: false,

3135+

});

3136+

expect(run).toHaveBeenNthCalledWith(2, "groq", "llama-3.3-70b-versatile", {

3137+

isFinalFallbackAttempt: true,

30993138

});

3100-

expect(run).toHaveBeenNthCalledWith(2, "groq", "llama-3.3-70b-versatile");

31013139

});

3102314031033141

it("limits cooldown probes to one per provider before moving to cross-provider fallback", async () => {

@@ -3134,8 +3172,11 @@ describe("runWithModelFallback", () => {

31343172

expect(run).toHaveBeenCalledTimes(2);

31353173

expect(run).toHaveBeenNthCalledWith(1, "anthropic", "claude-opus-4-6", {

31363174

allowTransientCooldownProbe: true,

3175+

isFinalFallbackAttempt: false,

3176+

});

3177+

expect(run).toHaveBeenNthCalledWith(2, "groq", "llama-3.3-70b-versatile", {

3178+

isFinalFallbackAttempt: true,

31373179

});

3138-

expect(run).toHaveBeenNthCalledWith(2, "groq", "llama-3.3-70b-versatile");

31393180

});

3140318131413182

it("does not consume transient probe slot when first same-provider probe fails with model_not_found", async () => {

@@ -3172,9 +3213,11 @@ describe("runWithModelFallback", () => {

31723213

expect(run).toHaveBeenCalledTimes(2);

31733214

expect(run).toHaveBeenNthCalledWith(1, "anthropic", "claude-opus-4-6", {

31743215

allowTransientCooldownProbe: true,

3216+

isFinalFallbackAttempt: false,

31753217

});

31763218

expect(run).toHaveBeenNthCalledWith(2, "anthropic", "claude-sonnet-4-5", {

31773219

allowTransientCooldownProbe: true,

3220+

isFinalFallbackAttempt: false,

31783221

});

31793222

});

31803223

});