From fe8faf96b6890da5babaa7f0ade667aeb97d8dab Mon Sep 17 00:00:00 2001 From: Yuichi Uemura Date: Wed, 1 Jul 2026 23:48:45 +0900 Subject: [PATCH] fix(codex): grace fallback for thread/resume failure on Codex 0.142+ Codex 0.142+ --remote sessions may not create a rollout, causing thread/resume requests to fail. turn/start only needs threadId, so keep the bridge alive by falling back to the idle state when resume fails. Follow-up to 2f94765 (fix(codex): keep Codex working across 0.142 upgrades). --- scripts/drivers/types/codex/codex-bridge.js | 33 +++++++++++++-------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/scripts/drivers/types/codex/codex-bridge.js b/scripts/drivers/types/codex/codex-bridge.js index 2525c25b..5fceac3d 100755 --- a/scripts/drivers/types/codex/codex-bridge.js +++ b/scripts/drivers/types/codex/codex-bridge.js @@ -772,19 +772,28 @@ class CodexBridge { console.error(`codex-bridge: discovered loaded thread ${this.threadId}`); } if (this.threadId) { - const response = await this.client.request("thread/resume", { - threadId: this.threadId, - cwd: this.opts.project, - runtimeWorkspaceRoots: [this.opts.project], - excludeTurns: true, - }); - if (!response.thread || response.thread.id !== this.threadId) { - die("thread/resume did not return the requested thread id"); + try { + const response = await this.client.request("thread/resume", { + threadId: this.threadId, + cwd: this.opts.project, + runtimeWorkspaceRoots: [this.opts.project], + excludeTurns: true, + }); + if (!response.thread || response.thread.id !== this.threadId) { + die("thread/resume did not return the requested thread id"); + } + const type = response.thread.status && response.thread.status.type; + this.threadIdle = type !== "active"; + this.turnActive = type === "active"; + console.error(`codex-bridge: resumed thread ${this.threadId}`); + } catch (err) { + // Codex 0.142+ の --remote セッションでは rollout が作成されないため + // thread/resume が失敗する。turn/start は threadId だけで動作するので + // デフォルト状態 (idle) で続行する。 + console.error(`codex-bridge: thread/resume failed (${err.message}); proceeding without resume`); + this.threadIdle = true; + this.turnActive = false; } - const type = response.thread.status && response.thread.status.type; - this.threadIdle = type !== "active"; - this.turnActive = type === "active"; - console.error(`codex-bridge: resumed thread ${this.threadId}`); return; } const response = await this.client.request("thread/start", {