fix: replace stale codex threads
This commit is contained in:
@@ -453,7 +453,8 @@ async function runCodexStdioTurnWithSession(options: CodexStdioTurnOptions, sess
|
||||
} catch (error) {
|
||||
const failure = normalizeFailure(error);
|
||||
if (!isMissingRolloutThreadResumeFailure(failure)) throw error;
|
||||
throw threadResumeFailure(options.threadId, failure);
|
||||
emitEvent({ type: "backend_status", payload: threadResumeNonResumablePayload(options.threadId, failure) });
|
||||
threadId = await startThread("thread/replacement-start");
|
||||
}
|
||||
} else {
|
||||
threadId = await startThread();
|
||||
@@ -930,6 +931,18 @@ function threadResumeFailure(threadId: string, error: CodexStdioFailure): CodexS
|
||||
);
|
||||
}
|
||||
|
||||
function threadResumeNonResumablePayload(threadId: string, error: CodexStdioFailure): JsonRecord {
|
||||
return {
|
||||
phase: "thread/resume:non-resumable",
|
||||
requestedThreadId: threadId,
|
||||
originalFailureKind: error.failureKind,
|
||||
originalPhase: error.phase,
|
||||
originalDetails: redactJson(error.details),
|
||||
replacement: "thread/start",
|
||||
valuesPrinted: false,
|
||||
};
|
||||
}
|
||||
|
||||
function classifyCodexErrorRecord(error: JsonRecord, fallback: FailureKind): FailureKind {
|
||||
const parts: string[] = [];
|
||||
if (typeof error.message === "string") parts.push(error.message);
|
||||
|
||||
Reference in New Issue
Block a user