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

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
爱范儿
爱范儿
WordPress大学
WordPress大学
博客园 - 三生石上(FineUI控件)
J
Java Code Geeks
Vercel News
Vercel News
aimingoo的专栏
aimingoo的专栏
T
Tailwind CSS Blog
罗磊的独立博客
B
Blog
博客园_首页
A
About on SuperTechFans
有赞技术团队
有赞技术团队
V
V2EX
U
Unit 42
I
InfoQ
IT之家
IT之家
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
博客园 - 叶小钗
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
The Cloudflare Blog
H
Help Net Security

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(agents): clear poisoned claude cli sessions (#81247) ...
giodl73-repo · 2026-05-17 · via Recent Commits to openclaw:main

@@ -187,6 +187,39 @@ describe("CLI attempt execution", () => {

187187

});

188188

}

189189190+

async function writeClaudeCliAssistantTranscript(cliSessionId: string) {

191+

const homeDir = path.join(tmpDir, `home-${cliSessionId}`);

192+

const projectsDir = path.join(homeDir, ".claude", "projects", "demo-workspace");

193+

process.env.HOME = homeDir;

194+

await fs.mkdir(projectsDir, { recursive: true });

195+

await fs.writeFile(

196+

path.join(projectsDir, `${cliSessionId}.jsonl`),

197+

`${JSON.stringify({

198+

type: "assistant",

199+

message: { role: "assistant", content: [{ type: "text", text: "old reply" }] },

200+

})}\n`,

201+

"utf-8",

202+

);

203+

}

204+205+

function makeClaudeCliSessionEntry(

206+

openclawSessionId: string,

207+

cliSessionId: string,

208+

): SessionEntry {

209+

return {

210+

sessionId: openclawSessionId,

211+

updatedAt: Date.now(),

212+

cliSessionBindings: {

213+

"claude-cli": {

214+

sessionId: cliSessionId,

215+

authProfileId: "anthropic:claude-cli",

216+

},

217+

},

218+

cliSessionIds: { "claude-cli": cliSessionId },

219+

claudeCliSessionId: cliSessionId,

220+

};

221+

}

222+190223

it("clears stale Claude CLI session IDs before retrying after session expiration", async () => {

191224

const sessionKey = "agent:main:subagent:cli-expired";

192225

const homeDir = path.join(tmpDir, "home");

@@ -265,6 +298,73 @@ describe("CLI attempt execution", () => {

265298

expect(persisted[sessionKey]?.claudeCliSessionId).toBeUndefined();

266299

});

267300301+

it("clears reused Claude CLI session IDs after AbortError without retrying", async () => {

302+

const sessionKey = "agent:main:direct:cli-abort";

303+

const cliSessionId = "abort-poisoned-session";

304+

await writeClaudeCliAssistantTranscript(cliSessionId);

305+

const sessionEntry = makeClaudeCliSessionEntry("session-cli-abort", cliSessionId);

306+

const sessionStore: Record<string, SessionEntry> = { [sessionKey]: sessionEntry };

307+

await fs.writeFile(storePath, JSON.stringify(sessionStore, null, 2), "utf-8");

308+

const abortError = Object.assign(new Error("aborted"), { name: "AbortError" });

309+

runCliAgentMock.mockRejectedValueOnce(abortError);

310+311+

await expect(

312+

runClaudeCliAttempt({

313+

sessionKey,

314+

sessionEntry,

315+

sessionStore,

316+

body: "resume after abort",

317+

runId: "run-cli-abort",

318+

}),

319+

).rejects.toMatchObject({ name: "AbortError" });

320+321+

expect(runCliAgentMock).toHaveBeenCalledTimes(1);

322+

expect(firstRunCliAgentArg().cliSessionId).toBe(cliSessionId);

323+

expect(sessionStore[sessionKey]?.cliSessionBindings?.["claude-cli"]).toBeUndefined();

324+

expect(sessionStore[sessionKey]?.cliSessionIds?.["claude-cli"]).toBeUndefined();

325+

expect(sessionStore[sessionKey]?.claudeCliSessionId).toBeUndefined();

326+327+

const persisted = JSON.parse(await fs.readFile(storePath, "utf-8")) as Record<

328+

string,

329+

SessionEntry

330+

>;

331+

expect(persisted[sessionKey]?.cliSessionBindings?.["claude-cli"]).toBeUndefined();

332+

expect(persisted[sessionKey]?.cliSessionIds?.["claude-cli"]).toBeUndefined();

333+

expect(persisted[sessionKey]?.claudeCliSessionId).toBeUndefined();

334+

});

335+336+

it("clears reused Claude CLI session IDs after non-expired failover without retrying", async () => {

337+

const sessionKey = "agent:main:direct:cli-timeout";

338+

const cliSessionId = "timeout-poisoned-session";

339+

await writeClaudeCliAssistantTranscript(cliSessionId);

340+

const sessionEntry = makeClaudeCliSessionEntry("session-cli-timeout", cliSessionId);

341+

const sessionStore: Record<string, SessionEntry> = { [sessionKey]: sessionEntry };

342+

await fs.writeFile(storePath, JSON.stringify(sessionStore, null, 2), "utf-8");

343+

runCliAgentMock.mockRejectedValueOnce(

344+

new FailoverError("CLI produced no output for 60s", {

345+

reason: "timeout",

346+

provider: "claude-cli",

347+

model: "opus",

348+

}),

349+

);

350+351+

await expect(

352+

runClaudeCliAttempt({

353+

sessionKey,

354+

sessionEntry,

355+

sessionStore,

356+

body: "resume after timeout",

357+

runId: "run-cli-timeout",

358+

}),

359+

).rejects.toMatchObject({ name: "FailoverError", reason: "timeout" });

360+361+

expect(runCliAgentMock).toHaveBeenCalledTimes(1);

362+

expect(firstRunCliAgentArg().cliSessionId).toBe(cliSessionId);

363+

expect(sessionStore[sessionKey]?.cliSessionBindings?.["claude-cli"]).toBeUndefined();

364+

expect(sessionStore[sessionKey]?.cliSessionIds?.["claude-cli"]).toBeUndefined();

365+

expect(sessionStore[sessionKey]?.claudeCliSessionId).toBeUndefined();

366+

});

367+268368

it("does not pass --resume when the stored Claude CLI transcript is missing", async () => {

269369

const sessionKey = "agent:main:direct:claude-missing-transcript";

270370

const homeDir = path.join(tmpDir, "home");