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

推荐订阅源

WordPress大学
WordPress大学
A
About on SuperTechFans
量子位
B
Blog RSS Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园_首页
MongoDB | Blog
MongoDB | Blog
小众软件
小众软件
Blog — PlanetScale
Blog — PlanetScale
Microsoft Azure Blog
Microsoft Azure Blog
V
V2EX
Google DeepMind News
Google DeepMind News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
G
Google Developers Blog
U
Unit 42
D
DataBreaches.Net
博客园 - Franky
D
Docker
宝玉的分享
宝玉的分享
Y
Y Combinator Blog
月光博客
月光博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Hugging Face - Blog
Hugging Face - 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
fix: recover missing Codex bound threads · openclaw/openc...
keshavbotage · 2026-05-05 · via Recent Commits to openclaw:main

@@ -10,8 +10,11 @@ import { CODEX_CONTROL_METHODS } from "./app-server/capabilities.js";

1010

import {

1111

codexSandboxPolicyForTurn,

1212

resolveCodexAppServerRuntimeOptions,

13+

type CodexAppServerApprovalPolicy,

14+

type CodexAppServerSandboxMode,

1315

} from "./app-server/config.js";

1416

import {

17+

type CodexServiceTier,

1518

type CodexThreadResumeResponse,

1619

type CodexThreadStartResponse,

1720

type CodexTurnStartResponse,

@@ -59,6 +62,9 @@ type CodexConversationStartParams = {

5962

model?: string;

6063

modelProvider?: string;

6164

authProfileId?: string;

65+

approvalPolicy?: CodexAppServerApprovalPolicy;

66+

sandbox?: CodexAppServerSandboxMode;

67+

serviceTier?: CodexServiceTier;

6268

};

63696470

type BoundTurnResult = {

@@ -100,6 +106,9 @@ export async function startCodexConversationThread(

100106

model: params.model,

101107

modelProvider: params.modelProvider,

102108

authProfileId,

109+

approvalPolicy: params.approvalPolicy,

110+

sandbox: params.sandbox,

111+

serviceTier: params.serviceTier,

103112

config: params.config,

104113

});

105114

} else {

@@ -110,6 +119,9 @@ export async function startCodexConversationThread(

110119

model: params.model,

111120

modelProvider: params.modelProvider,

112121

authProfileId,

122+

approvalPolicy: params.approvalPolicy,

123+

sandbox: params.sandbox,

124+

serviceTier: params.serviceTier,

113125

config: params.config,

114126

});

115127

}

@@ -137,7 +149,7 @@ export async function handleCodexConversationInboundClaim(

137149

}

138150

try {

139151

const result = await enqueueBoundTurn(data.sessionFile, () =>

140-

runBoundTurn({

152+

runBoundTurnWithMissingThreadRecovery({

141153

data,

142154

prompt,

143155

event,

@@ -177,9 +189,14 @@ async function attachExistingThread(params: {

177189

model?: string;

178190

modelProvider?: string;

179191

authProfileId?: string;

192+

approvalPolicy?: CodexAppServerApprovalPolicy;

193+

sandbox?: CodexAppServerSandboxMode;

194+

serviceTier?: CodexServiceTier;

180195

config?: CodexAppServerAuthProfileLookup["config"];

181196

}): Promise<void> {

182-

const runtime = resolveCodexAppServerRuntimeOptions({ pluginConfig: params.pluginConfig });

197+

const runtime = resolveCodexAppServerRuntimeOptions({

198+

pluginConfig: params.pluginConfig,

199+

});

183200

const modelProvider = resolveThreadRequestModelProvider({

184201

authProfileId: params.authProfileId,

185202

modelProvider: params.modelProvider,

@@ -196,10 +213,12 @@ async function attachExistingThread(params: {

196213

threadId: params.threadId,

197214

...(params.model ? { model: params.model } : {}),

198215

...(modelProvider ? { modelProvider } : {}),

199-

approvalPolicy: runtime.approvalPolicy,

216+

approvalPolicy: params.approvalPolicy ?? runtime.approvalPolicy,

200217

approvalsReviewer: runtime.approvalsReviewer,

201-

sandbox: runtime.sandbox,

202-

...(runtime.serviceTier ? { serviceTier: runtime.serviceTier } : {}),

218+

sandbox: params.sandbox ?? runtime.sandbox,

219+

...((params.serviceTier ?? runtime.serviceTier)

220+

? { serviceTier: params.serviceTier ?? runtime.serviceTier }

221+

: {}),

203222

persistExtendedHistory: true,

204223

},

205224

{ timeoutMs: runtime.requestTimeoutMs },

@@ -217,9 +236,9 @@ async function attachExistingThread(params: {

217236

authProfileId: params.authProfileId,

218237

modelProvider: response.modelProvider ?? params.modelProvider,

219238

}),

220-

approvalPolicy: runtime.approvalPolicy,

221-

sandbox: runtime.sandbox,

222-

serviceTier: runtime.serviceTier,

239+

approvalPolicy: params.approvalPolicy ?? runtime.approvalPolicy,

240+

sandbox: params.sandbox ?? runtime.sandbox,

241+

serviceTier: params.serviceTier ?? runtime.serviceTier,

223242

},

224243

{

225244

config: params.config,

@@ -234,9 +253,14 @@ async function createThread(params: {

234253

model?: string;

235254

modelProvider?: string;

236255

authProfileId?: string;

256+

approvalPolicy?: CodexAppServerApprovalPolicy;

257+

sandbox?: CodexAppServerSandboxMode;

258+

serviceTier?: CodexServiceTier;

237259

config?: CodexAppServerAuthProfileLookup["config"];

238260

}): Promise<void> {

239-

const runtime = resolveCodexAppServerRuntimeOptions({ pluginConfig: params.pluginConfig });

261+

const runtime = resolveCodexAppServerRuntimeOptions({

262+

pluginConfig: params.pluginConfig,

263+

});

240264

const modelProvider = resolveThreadRequestModelProvider({

241265

authProfileId: params.authProfileId,

242266

modelProvider: params.modelProvider,

@@ -253,10 +277,12 @@ async function createThread(params: {

253277

cwd: params.workspaceDir,

254278

...(params.model ? { model: params.model } : {}),

255279

...(modelProvider ? { modelProvider } : {}),

256-

approvalPolicy: runtime.approvalPolicy,

280+

approvalPolicy: params.approvalPolicy ?? runtime.approvalPolicy,

257281

approvalsReviewer: runtime.approvalsReviewer,

258-

sandbox: runtime.sandbox,

259-

...(runtime.serviceTier ? { serviceTier: runtime.serviceTier } : {}),

282+

sandbox: params.sandbox ?? runtime.sandbox,

283+

...((params.serviceTier ?? runtime.serviceTier)

284+

? { serviceTier: params.serviceTier ?? runtime.serviceTier }

285+

: {}),

260286

developerInstructions:

261287

"This Codex thread is bound to an OpenClaw conversation. Answer normally; OpenClaw will deliver your final response back to the conversation.",

262288

experimentalRawEvents: true,

@@ -276,9 +302,9 @@ async function createThread(params: {

276302

authProfileId: params.authProfileId,

277303

modelProvider: response.modelProvider ?? params.modelProvider,

278304

}),

279-

approvalPolicy: runtime.approvalPolicy,

280-

sandbox: runtime.sandbox,

281-

serviceTier: runtime.serviceTier,

305+

approvalPolicy: params.approvalPolicy ?? runtime.approvalPolicy,

306+

sandbox: params.sandbox ?? runtime.sandbox,

307+

serviceTier: params.serviceTier ?? runtime.serviceTier,

282308

},

283309

{

284310

config: params.config,

@@ -293,7 +319,9 @@ async function runBoundTurn(params: {

293319

pluginConfig?: unknown;

294320

timeoutMs?: number;

295321

}): Promise<BoundTurnResult> {

296-

const runtime = resolveCodexAppServerRuntimeOptions({ pluginConfig: params.pluginConfig });

322+

const runtime = resolveCodexAppServerRuntimeOptions({

323+

pluginConfig: params.pluginConfig,

324+

});

297325

const binding = await readCodexAppServerBinding(params.data.sessionFile);

298326

const threadId = binding?.threadId;

299327

if (!threadId) {

@@ -350,7 +378,10 @@ async function runBoundTurn(params: {

350378

"turn/start",

351379

{

352380

threadId,

353-

input: buildCodexConversationTurnInput({ prompt: params.prompt, event: params.event }),

381+

input: buildCodexConversationTurnInput({

382+

prompt: params.prompt,

383+

event: params.event,

384+

}),

354385

cwd: binding.cwd || params.data.workspaceDir,

355386

approvalPolicy: binding.approvalPolicy ?? runtime.approvalPolicy,

356387

approvalsReviewer: runtime.approvalsReviewer,

@@ -389,6 +420,39 @@ async function runBoundTurn(params: {

389420

}

390421

}

391422423+

async function runBoundTurnWithMissingThreadRecovery(params: {

424+

data: CodexConversationBindingData;

425+

prompt: string;

426+

event: PluginHookInboundClaimEvent;

427+

pluginConfig?: unknown;

428+

timeoutMs?: number;

429+

}): Promise<BoundTurnResult> {

430+

try {

431+

return await runBoundTurn(params);

432+

} catch (error) {

433+

if (!isCodexThreadNotFoundError(error)) {

434+

throw error;

435+

}

436+

const binding = await readCodexAppServerBinding(params.data.sessionFile);

437+

await startCodexConversationThread({

438+

pluginConfig: params.pluginConfig,

439+

sessionFile: params.data.sessionFile,

440+

workspaceDir: binding?.cwd || params.data.workspaceDir,

441+

model: binding?.model,

442+

modelProvider: binding?.modelProvider,

443+

authProfileId: binding?.authProfileId,

444+

approvalPolicy: binding?.approvalPolicy,

445+

sandbox: binding?.sandbox,

446+

serviceTier: binding?.serviceTier,

447+

});

448+

return await runBoundTurn(params);

449+

}

450+

}

451+452+

function isCodexThreadNotFoundError(error: unknown): boolean {

453+

return /\bthread not found:/iu.test(formatErrorMessage(error));

454+

}

455+392456

function enqueueBoundTurn<T>(key: string, run: () => Promise<T>): Promise<T> {

393457

const state = getGlobalState();

394458

const previous = state.queues.get(key) ?? Promise.resolve();