fix(server): Stop ends a Codex command after its thread was settled (#15546)
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
250e052f44
commit
cf3e714b0f
2 files changed
+18
-3
No files matched your search
@@ -3917,7 +3917,9 @@ describe("CodexAdapterV2 post-settle continuation", () => {
|
||||
),
|
||||
);
|
||||
|
||||
const backgroundStopCases = [true, false, "still_running"] as const;
|
||||
// "thread_unloaded": the thread was settled, so T3 unsubscribed and Codex
|
||||
// unloaded it (killing its terminals) before Stop arrived.
|
||||
const backgroundStopCases = [true, false, "still_running", "thread_unloaded"] as const;
|
||||
const makeBackgroundStopTranscript = (terminated: (typeof backgroundStopCases)[number]) => {
|
||||
const stillRunning = terminated === "still_running";
|
||||
return makeCodexReplayTranscript({
|
||||
@@ -3936,9 +3938,15 @@ describe("CodexAdapterV2 post-settle continuation", () => {
|
||||
{
|
||||
type: "emit_inbound",
|
||||
label: "terminate-background-command",
|
||||
frame: { id: 4, result: { terminated: terminated === true } },
|
||||
frame:
|
||||
terminated === "thread_unloaded"
|
||||
? {
|
||||
id: 4,
|
||||
error: { code: -32600, message: `thread not found: ${BG_NATIVE_THREAD}` },
|
||||
}
|
||||
: { id: 4, result: { terminated: terminated === true } },
|
||||
},
|
||||
...(terminated !== true
|
||||
...(terminated === false || stillRunning
|
||||
? [
|
||||
{
|
||||
type: "expect_outbound" as const,
|
||||
|
||||
@@ -2054,6 +2054,13 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
|
||||
Effect.catchTags({
|
||||
CodexAppServerProcessExitedError: () => Effect.succeed({ terminated: true }),
|
||||
CodexAppServerInputStreamEndedError: () => Effect.succeed({ terminated: true }),
|
||||
// The thread is unloaded, as Codex does a minute after a
|
||||
// settle or archive unsubscribes it. Unloading kills the
|
||||
// thread's terminals, so nothing is left to stop.
|
||||
CodexAppServerRequestError: (error) =>
|
||||
error.code === -32600 && error.errorMessage.startsWith("thread not found:")
|
||||
? Effect.succeed({ terminated: true })
|
||||
: Effect.fail(error),
|
||||
}),
|
||||
);
|
||||
const result = yield* decodeCodexBackgroundTerminalTerminateResponse(response);
|
||||
|
||||
Reference in new issue
Block a user