fix(gateway): surface codex app-server returned failures (#93665)

* fix(gateway): surface codex app-server returned failures

* fix(auto-reply): retain codex app-server failures

* fix(agents): mark codex completion timeouts terminal

---------

Co-authored-by: Alex Tang <tangli1987118@hotmail.com>
Co-authored-by: Vincent Koc <25068+vincentkoc@users.noreply.github.com>
This commit is contained in:
litang9
2026-06-17 01:20:34 +08:00
committed by GitHub
parent 1469441ff4
commit d1e20d2f29
2 changed files with 27 additions and 0 deletions
@@ -235,6 +235,11 @@ describe("runEmbeddedAgent Codex app-server recovery", () => {
});
expect(result.meta.timeoutPhase).toBe("provider");
expect(result.meta.providerStarted).toBe(true);
expect(result.meta.error).toEqual({
kind: "incomplete_turn",
message: CODEX_MISSING_TERMINAL_MESSAGE,
fallbackSafe: false,
});
expect(mockedRunEmbeddedAttempt).toHaveBeenCalledTimes(2);
expect(mockedMarkAuthProfileFailure).not.toHaveBeenCalled();
});
@@ -264,6 +269,11 @@ describe("runEmbeddedAgent Codex app-server recovery", () => {
isError: true,
text: CODEX_MISSING_TERMINAL_MESSAGE,
});
expect(result.meta.error).toEqual({
kind: "incomplete_turn",
message: CODEX_MISSING_TERMINAL_MESSAGE,
fallbackSafe: false,
});
expect(mockedRunEmbeddedAttempt).toHaveBeenCalledTimes(1);
expect(mockedMarkAuthProfileFailure).not.toHaveBeenCalled();
});
@@ -316,6 +326,12 @@ describe("runEmbeddedAgent Codex app-server recovery", () => {
});
expect(result.meta.replayInvalid).toBe(true);
expect(result.meta.livenessState).toBe("abandoned");
expect(result.meta.error).toEqual({
kind: "incomplete_turn",
message:
"Codex stopped before confirming the turn was complete. Some work may already have been performed; verify the current state before retrying.",
fallbackSafe: false,
});
expect(mockedRunEmbeddedAttempt).toHaveBeenCalledTimes(1);
expect(mockedMarkAuthProfileFailure).not.toHaveBeenCalled();
});
+11
View File
@@ -3377,6 +3377,17 @@ async function runEmbeddedAgentInternal(
livenessState,
timeoutPhase,
providerStarted,
// Completion-idle recovery is exhausted here. Keep this terminal so
// model fallback cannot replay a potentially still-active Codex turn.
...(shouldSurfaceCodexCompletionTimeout
? {
error: {
kind: "incomplete_turn" as const,
message: timeoutText,
fallbackSafe: false,
},
}
: {}),
toolSummary: attemptToolSummary,
...(failureSignal ? { failureSignal } : {}),
agentHarnessResultClassification: attempt.agentHarnessResultClassification,