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

推荐订阅源

大猫的无限游戏
大猫的无限游戏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
Docker
酷 壳 – CoolShell
酷 壳 – CoolShell
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
美团技术团队
量子位
M
MIT News - Artificial intelligence
Apple Machine Learning Research
Apple Machine Learning Research
阮一峰的网络日志
阮一峰的网络日志
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
腾讯CDC
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
小众软件
小众软件
博客园 - 司徒正美
罗磊的独立博客
云风的 BLOG
云风的 BLOG
B
Blog RSS Feed
博客园 - 聂微东

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(diagnostics): reclaim wedged session lanes with a sta...
openperf · 2026-05-25 · via Recent Commits to openclaw:main

@@ -14,6 +14,7 @@ const mocks = vi.hoisted(() => ({

1414

resolveActiveEmbeddedRunHandleSessionId: vi.fn(),

1515

resolveEmbeddedSessionLane: vi.fn((key: string) => `session:${key}`),

1616

waitForEmbeddedPiRunEnd: vi.fn(),

17+

getDiagnosticSessionActivitySnapshot: vi.fn(),

1718

diag: {

1819

debug: vi.fn(),

1920

warn: vi.fn(),

@@ -60,6 +61,10 @@ vi.mock("./diagnostic-runtime.js", () => ({

6061

diagnosticLogger: mocks.diag,

6162

}));

626364+

vi.mock("./diagnostic-run-activity.js", () => ({

65+

getDiagnosticSessionActivitySnapshot: mocks.getDiagnosticSessionActivitySnapshot,

66+

}));

67+6368

import {

6469

testing,

6570

recoverStuckDiagnosticSession,

@@ -85,6 +90,10 @@ function resetMocks() {

8590

mocks.resolveActiveEmbeddedRunHandleSessionId.mockReset();

8691

mocks.resolveEmbeddedSessionLane.mockClear();

8792

mocks.waitForEmbeddedPiRunEnd.mockReset();

93+

mocks.getDiagnosticSessionActivitySnapshot.mockReset();

94+

// Default: no progress signal, so the staleness gate stays off unless a test

95+

// opts in by returning a stale lastProgressAgeMs.

96+

mocks.getDiagnosticSessionActivitySnapshot.mockReturnValue({});

8897

mocks.diag.debug.mockReset();

8998

mocks.diag.warn.mockReset();

9099

}

@@ -121,6 +130,26 @@ describe("stuck session recovery", () => {

121130

]);

122131

});

123132133+

it("reclaims a stale active embedded run with queued work and no forward progress (#85639)", async () => {

134+

mocks.resolveActiveEmbeddedRunHandleSessionId.mockReturnValue("session-1");

135+

mocks.getDiagnosticSessionActivitySnapshot.mockReturnValue({

136+

lastProgressAgeMs: 10 * 60_000,

137+

});

138+

mocks.abortEmbeddedPiRun.mockReturnValue(true);

139+

mocks.waitForEmbeddedPiRunEnd.mockResolvedValue(true);

140+141+

const outcome = await recoverStuckDiagnosticSession({

142+

sessionId: "session-1",

143+

sessionKey: "agent:main:main",

144+

ageMs: 180_000,

145+

queueDepth: 1,

146+

});

147+148+

expect(mocks.abortEmbeddedPiRun).toHaveBeenCalledWith("session-1");

149+

expect(outcome.status).toBe("aborted");

150+

expect(warnLogMessages().some((m) => m.includes("reclaiming stale active run"))).toBe(true);

151+

});

152+124153

it("aborts an active embedded run when active abort recovery is enabled", async () => {

125154

mocks.resolveActiveEmbeddedRunHandleSessionId.mockReturnValue("session-1");

126155

mocks.abortEmbeddedPiRun.mockReturnValue(true);

@@ -292,6 +321,107 @@ describe("stuck session recovery", () => {

292321

]);

293322

});

294323324+

it("reclaims stale leaked reply work with queued work and no forward progress (#85639)", async () => {

325+

mocks.resolveActiveEmbeddedRunSessionId.mockReturnValue("queued-reply-session");

326+

mocks.resolveActiveEmbeddedRunHandleSessionId.mockReturnValue(undefined);

327+

mocks.isEmbeddedPiRunActive.mockReturnValue(true);

328+

mocks.isEmbeddedPiRunHandleActive.mockReturnValue(false);

329+

// The "active" run has made no forward progress for well past the staleness

330+

// window — a leaked/dead handle, not genuine work.

331+

mocks.getDiagnosticSessionActivitySnapshot.mockReturnValue({ lastProgressAgeMs: 10 * 60_000 });

332+

mocks.abortEmbeddedPiRun.mockReturnValue(true);

333+

mocks.waitForEmbeddedPiRunEnd.mockResolvedValue(true);

334+335+

const outcome = await recoverStuckDiagnosticSession({

336+

sessionId: "queued-reply-session",

337+

sessionKey: "agent:main:main",

338+

ageMs: 180_000,

339+

queueDepth: 1,

340+

});

341+342+

// Reclaimed (aborted) instead of skipping with active_reply_work.

343+

expect(mocks.abortEmbeddedPiRun).toHaveBeenCalledWith("queued-reply-session");

344+

expect(outcome.status).not.toBe("skipped");

345+

expect(warnLogMessages().some((m) => m.includes("reclaiming stale active reply work"))).toBe(

346+

true,

347+

);

348+

});

349+350+

it("honors an operator-raised stuck-session abort threshold for stale reclaim (#85639)", async () => {

351+

mocks.resolveActiveEmbeddedRunSessionId.mockReturnValue("queued-reply-session");

352+

mocks.resolveActiveEmbeddedRunHandleSessionId.mockReturnValue(undefined);

353+

mocks.isEmbeddedPiRunActive.mockReturnValue(true);

354+

mocks.isEmbeddedPiRunHandleActive.mockReturnValue(false);

355+

mocks.abortEmbeddedPiRun.mockReturnValue(true);

356+

mocks.waitForEmbeddedPiRunEnd.mockResolvedValue(true);

357+358+

// Operator raised the abort threshold to 20 min to protect slow active work.

359+

const raisedAbortMs = 20 * 60_000;

360+361+

// Below the raised threshold (10 min): keep the lane, do not reclaim.

362+

mocks.getDiagnosticSessionActivitySnapshot.mockReturnValue({ lastProgressAgeMs: 10 * 60_000 });

363+

const kept = await recoverStuckDiagnosticSession({

364+

sessionId: "queued-reply-session",

365+

sessionKey: "agent:main:main",

366+

ageMs: 180_000,

367+

queueDepth: 1,

368+

staleActiveProgressAbortMs: raisedAbortMs,

369+

});

370+

expect(mocks.abortEmbeddedPiRun).not.toHaveBeenCalled();

371+

expect(kept.status).toBe("skipped");

372+373+

// Past the raised threshold (25 min): reclaim.

374+

mocks.getDiagnosticSessionActivitySnapshot.mockReturnValue({ lastProgressAgeMs: 25 * 60_000 });

375+

const reclaimed = await recoverStuckDiagnosticSession({

376+

sessionId: "queued-reply-session",

377+

sessionKey: "agent:main:main",

378+

ageMs: 180_000,

379+

queueDepth: 1,

380+

staleActiveProgressAbortMs: raisedAbortMs,

381+

});

382+

expect(mocks.abortEmbeddedPiRun).toHaveBeenCalledWith("queued-reply-session");

383+

expect(reclaimed.status).not.toBe("skipped");

384+

});

385+386+

it("keeps the lane when active reply work is still progressing", async () => {

387+

mocks.resolveActiveEmbeddedRunSessionId.mockReturnValue("queued-reply-session");

388+

mocks.resolveActiveEmbeddedRunHandleSessionId.mockReturnValue(undefined);

389+

mocks.isEmbeddedPiRunActive.mockReturnValue(true);

390+

mocks.isEmbeddedPiRunHandleActive.mockReturnValue(false);

391+

// Recent forward progress: a genuinely active run must not be reclaimed.

392+

mocks.getDiagnosticSessionActivitySnapshot.mockReturnValue({ lastProgressAgeMs: 5_000 });

393+394+

const outcome = await recoverStuckDiagnosticSession({

395+

sessionId: "queued-reply-session",

396+

sessionKey: "agent:main:main",

397+

ageMs: 180_000,

398+

queueDepth: 1,

399+

});

400+401+

expect(mocks.abortEmbeddedPiRun).not.toHaveBeenCalled();

402+

expect(outcome.status).toBe("skipped");

403+

expect(warnLogMessages().some((m) => m.includes("reason=active_reply_work"))).toBe(true);

404+

});

405+406+

it("does not reclaim stale reply work when no work is queued", async () => {

407+

mocks.resolveActiveEmbeddedRunSessionId.mockReturnValue("queued-reply-session");

408+

mocks.resolveActiveEmbeddedRunHandleSessionId.mockReturnValue(undefined);

409+

mocks.isEmbeddedPiRunActive.mockReturnValue(true);

410+

mocks.isEmbeddedPiRunHandleActive.mockReturnValue(false);

411+

mocks.getDiagnosticSessionActivitySnapshot.mockReturnValue({ lastProgressAgeMs: 10 * 60_000 });

412+413+

const outcome = await recoverStuckDiagnosticSession({

414+

sessionId: "queued-reply-session",

415+

sessionKey: "agent:main:main",

416+

ageMs: 180_000,

417+

queueDepth: 0,

418+

});

419+420+

expect(mocks.abortEmbeddedPiRun).not.toHaveBeenCalled();

421+

expect(outcome.status).toBe("skipped");

422+

expect(warnLogMessages().some((m) => m.includes("reason=active_reply_work"))).toBe(true);

423+

});

424+295425

it("aborts stale reply work without an embedded handle when active abort recovery is enabled", async () => {

296426

mocks.resolveActiveEmbeddedRunSessionId.mockReturnValue("queued-reply-session");

297427

mocks.resolveActiveEmbeddedRunHandleSessionId.mockReturnValue(undefined);