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

推荐订阅源

The GitHub Blog
The GitHub Blog
博客园 - 三生石上(FineUI控件)
V
V2EX
博客园 - 司徒正美
小众软件
小众软件
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tailwind CSS Blog
Last Week in AI
Last Week in AI
雷峰网
雷峰网
月光博客
月光博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
SegmentFault 最新的问题
美团技术团队
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
爱范儿
爱范儿
博客园 - 聂微东
量子位
J
Java Code Geeks
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Vercel News
Vercel News

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(failover): defer profile cooldown marking to unblock ...
jeremyknows · 2026-05-08 · via Recent Commits to openclaw:main

@@ -83,6 +83,7 @@ const installRunEmbeddedMocks = () => {

8383

};

84848585

let runEmbeddedPiAgent: typeof import("./pi-embedded-runner/run.js").runEmbeddedPiAgent;

86+

let authProfileUsageTesting: typeof import("./auth-profiles/usage.js").__testing;

8687

let createDiagnosticLogRecordCaptureFn: typeof import("../logging/test-helpers/diagnostic-log-capture.js").createDiagnosticLogRecordCapture;

8788

let cleanupLogCapture: (() => void) | undefined;

8889

let resetLoggerFn: typeof import("../logging/logger.js").resetLogger;

@@ -93,6 +94,7 @@ beforeAll(async () => {

9394

vi.resetModules();

9495

installRunEmbeddedMocks();

9596

({ runEmbeddedPiAgent } = await import("./pi-embedded-runner/run.js"));

97+

({ __testing: authProfileUsageTesting } = await import("./auth-profiles/usage.js"));

9698

({ createDiagnosticLogRecordCapture: createDiagnosticLogRecordCaptureFn } =

9799

await import("../logging/test-helpers/diagnostic-log-capture.js"));

98100

({ resetLogger: resetLoggerFn, setLoggerOverride: setLoggerOverrideFn } =

@@ -128,6 +130,7 @@ beforeEach(() => {

128130129131

afterEach(() => {

130132

globalThis.fetch = originalFetch;

133+

authProfileUsageTesting.setDepsForTest(null);

131134

cleanupLogCapture?.();

132135

cleanupLogCapture = undefined;

133136

setLoggerOverrideFn(null);

@@ -905,6 +908,46 @@ describe("runEmbeddedPiAgent auth profile rotation", () => {

905908

expect(sleepWithAbortMock).not.toHaveBeenCalled();

906909

});

907910911+

it("starts the retry attempt before prompt failure cooldown marking finishes", async () => {

912+

let releaseMark: (() => void) | undefined;

913+

const markCanFinish = new Promise<void>((resolve) => {

914+

releaseMark = resolve;

915+

});

916+

let markStarted = false;

917+

authProfileUsageTesting.setDepsForTest({

918+

updateAuthProfileStoreWithLock: async () => {

919+

markStarted = true;

920+

await markCanFinish;

921+

return null;

922+

},

923+

});

924+925+

try {

926+

await withAgentWorkspace(async ({ agentDir, workspaceDir }) => {

927+

await writeAuthStore(agentDir);

928+

mockPromptErrorThenSuccessfulAttempt("rate limit exceeded");

929+930+

const runPromise = runAutoPinnedOpenAiTurn({

931+

agentDir,

932+

workspaceDir,

933+

sessionKey: "agent:test:prompt-deferred-mark",

934+

runId: "run:prompt-deferred-mark",

935+

});

936+937+

await vi.waitFor(() => expect(runEmbeddedAttemptMock).toHaveBeenCalledTimes(2));

938+

expect(markStarted).toBe(true);

939+

releaseMark?.();

940+

releaseMark = undefined;

941+

await runPromise;

942+943+

const usageStats = await readUsageStats(agentDir);

944+

expect(typeof usageStats["openai:p2"]?.lastUsed).toBe("number");

945+

});

946+

} finally {

947+

releaseMark?.();

948+

}

949+

});

950+908951

it("uses configured overload backoff before rotating profiles", async () => {

909952

const { usageStats } = await runAutoPinnedRotationCase({

910953

errorMessage: '{"type":"error","error":{"type":"overloaded_error","message":"Overloaded"}}',

@@ -1507,8 +1550,9 @@ describe("runEmbeddedPiAgent auth profile rotation", () => {

15071550

});

1508155115091552

it("skips profiles in cooldown when rotating after failure", async () => {

1510-

await withTimedAgentWorkspace(async ({ agentDir, workspaceDir, now }) => {

1553+

await withAgentWorkspace(async ({ agentDir, workspaceDir }) => {

15111554

const authPath = path.join(agentDir, "auth-profiles.json");

1555+

const p2CooldownUntil = Date.now() + 60 * 60 * 1000;

15121556

const payload = {

15131557

version: 1,

15141558

profiles: {

@@ -1518,7 +1562,7 @@ describe("runEmbeddedPiAgent auth profile rotation", () => {

15181562

},

15191563

usageStats: {

15201564

"openai:p1": { lastUsed: 1 },

1521-

"openai:p2": { cooldownUntil: now + 60 * 60 * 1000 }, // p2 in cooldown

1565+

"openai:p2": { cooldownUntil: p2CooldownUntil }, // p2 in cooldown

15221566

"openai:p3": { lastUsed: 3 },

15231567

},

15241568

};

@@ -1536,7 +1580,7 @@ describe("runEmbeddedPiAgent auth profile rotation", () => {

15361580

const usageStats = await readUsageStats(agentDir);

15371581

expect(typeof usageStats["openai:p1"]?.lastUsed).toBe("number");

15381582

expect(typeof usageStats["openai:p3"]?.lastUsed).toBe("number");

1539-

expect(usageStats["openai:p2"]?.cooldownUntil).toBe(now + 60 * 60 * 1000);

1583+

expect(usageStats["openai:p2"]?.cooldownUntil).toBe(p2CooldownUntil);

15401584

});

15411585

});

15421586

});