diff --git a/packages/server/src/server/agent/providers/codex-app-server-agent.test.ts b/packages/server/src/server/agent/providers/codex-app-server-agent.test.ts index 4ae8a43e96..06339278b6 100644 --- a/packages/server/src/server/agent/providers/codex-app-server-agent.test.ts +++ b/packages/server/src/server/agent/providers/codex-app-server-agent.test.ts @@ -66,7 +66,6 @@ interface CodexClientLike { type CodexTestSession = AgentSession & { connected: boolean; currentThreadId: string | null; - currentTurnId: string | null; activeForegroundTurnId: string | null; client: CodexClientLike | null; }; @@ -2799,56 +2798,6 @@ describe("Codex app-server provider", () => { } }); - test("interrupts the next turn after a prior identification wait is abandoned", async () => { - let turnStartCount = 0; - const interruptedTurns: unknown[] = []; - const appServer = createFakeCodexAppServer({ - "turn/start": async () => { - turnStartCount += 1; - return {}; - }, - "turn/interrupt": async (params) => { - interruptedTurns.push(params); - return {}; - }, - }); - const session = new CodexAppServerAgentSession( - createConfig({ cwd: "/workspace/project" }), - null, - createTestLogger(), - async () => appServer.child, - ); - - try { - const firstResult = session.run("First turn."); - await vi.waitFor(() => expect(turnStartCount).toBe(1)); - const firstInterrupt = session.interrupt(); - appServer.completeTurn({ turnId: "turn-first" }); - await expect(firstInterrupt).rejects.toThrow( - "Cannot interrupt Codex before turn/started identifies the active turn", - ); - await firstResult; - - const secondResult = session.run("Second turn."); - await vi.waitFor(() => expect(turnStartCount).toBe(2)); - const secondInterrupt = session.interrupt(); - appServer.startsTurn({ threadId: "thread-1", turnId: "turn-first" }); - - await vi.waitFor(() => expect(session.currentTurnId).toBeNull()); - expect(interruptedTurns).toEqual([]); - - appServer.startsTurn({ threadId: "thread-1", turnId: "turn-second" }); - await secondInterrupt; - - expect(interruptedTurns).toEqual([{ threadId: "thread-1", turnId: "turn-second" }]); - appServer.completeTurn({ turnId: "turn-second" }); - await secondResult; - appServer.assertNoErrors(); - } finally { - await session.close(); - } - }); - test("rejects an interrupt before Codex initializes the thread", async () => { const appServer = createFakeCodexAppServer(); const session = new CodexAppServerAgentSession( diff --git a/packages/server/src/server/agent/providers/codex-app-server-agent.ts b/packages/server/src/server/agent/providers/codex-app-server-agent.ts index d5b20cc5df..e17493f4e2 100644 --- a/packages/server/src/server/agent/providers/codex-app-server-agent.ts +++ b/packages/server/src/server/agent/providers/codex-app-server-agent.ts @@ -2264,7 +2264,6 @@ type ParsedCodexNotification = | { kind: "turn_started"; turnId: string; threadId: string | null } | { kind: "turn_completed"; - turnId: string | null; status: string; errorMessage: string | null; threadId: string | null; @@ -2415,7 +2414,6 @@ const CodexNotificationSchema = z.union([ .transform( ({ params }): ParsedCodexNotification => ({ kind: "turn_completed", - turnId: params.turn.id ?? null, status: params.turn.status, errorMessage: params.turn.error?.message ?? null, threadId: params.threadId ?? null, @@ -2836,7 +2834,6 @@ const CodexNotificationSchema = z.union([ .transform( ({ params }): ParsedCodexNotification => ({ kind: "turn_completed", - turnId: null, status: "interrupted", errorMessage: null, threadId: getCodexEventThreadId(params), @@ -2857,7 +2854,6 @@ const CodexNotificationSchema = z.union([ .transform( ({ params }): ParsedCodexNotification => ({ kind: "turn_completed", - turnId: null, status: "completed", errorMessage: null, threadId: getCodexEventThreadId(params), @@ -3113,7 +3109,6 @@ export class CodexAppServerAgentSession implements AgentSession { private currentMode: string; private currentThreadId: string | null = null; private currentTurnId: string | null = null; - private readonly finalizedNativeTurnIds = new Set(); private pendingForegroundTurnIdentification: { foregroundTurnId: string; promise: Promise; @@ -5336,9 +5331,6 @@ export class CodexAppServerAgentSession implements AgentSession { this.emitSubAgentActivityUpdate(subAgentCallId, "running"); return; } - if (this.finalizedNativeTurnIds.has(parsed.turnId)) { - return; - } this.currentTurnId = parsed.turnId; const pendingIdentification = this.pendingForegroundTurnIdentification; if ( @@ -5366,10 +5358,6 @@ export class CodexAppServerAgentSession implements AgentSession { this.emitSubAgentActivityUpdate(subAgentCallId, status); return; } - const finalizedTurnId = parsed.turnId ?? this.currentTurnId; - if (finalizedTurnId) { - this.finalizedNativeTurnIds.add(finalizedTurnId); - } if (parsed.status === "failed") { this.emitEvent({ type: "turn_failed", diff --git a/packages/server/src/server/agent/providers/codex/test-utils/fake-app-server.ts b/packages/server/src/server/agent/providers/codex/test-utils/fake-app-server.ts index b72379abcc..e9d6a10bdc 100644 --- a/packages/server/src/server/agent/providers/codex/test-utils/fake-app-server.ts +++ b/packages/server/src/server/agent/providers/codex/test-utils/fake-app-server.ts @@ -51,7 +51,7 @@ export interface FakeCodexAppServer { waitForTurnStart(): Promise; nextResponse(): Promise; startsTurn(params: { threadId: string; turnId?: string }): void; - completeTurn(params?: { threadId?: string; turnId?: string }): void; + completeTurn(params?: { threadId?: string }): void; startsSubAgent(params: { callId: string; threadId: string; @@ -325,7 +325,7 @@ export function createFakeCodexAppServer( method: "turn/completed", params: { threadId: params.threadId ?? "thread-1", - turn: { id: params.turnId, status: "completed" }, + turn: { status: "completed" }, }, })}\n`, );