[codex] Retry temporarily offline exec-server recovery (#30098)

## Summary

- retry ERS `409 environment_offline` responses inside the existing
exec-server recovery loop
- keep all other registry conflicts terminal
- add focused coverage for both cases

## Root cause

When an exec server disconnects and reconnects, the client already
starts recovery and calls ERS `/connect`. During the transient executor
presence gap, ERS can return `409 environment_offline`. The retry
classifier treated every 409 as terminal, so the first response aborted
the existing 25-second recovery window before the executor came back
online. That then caused active processes to be marked lost.

This change classifies only the structured `environment_offline`
conflict as retryable. Recovery continues with the existing bounded
deadline, exponential backoff, and jitter.

## Validation

- `just test -p codex-exec-server client::recovery::tests` — 4 passed
- `just fix -p codex-exec-server` — passed
- `just fmt` — passed
- Full `just test -p codex-exec-server` reached unrelated macOS
filesystem-sandbox integration failures because nested
`/usr/bin/sandbox-exec` is denied in this environment (`sandbox_apply:
Operation not permitted`).
This commit is contained in:
richardopenai authored and GitHub committed 2026-06-25 19:25:04 +00:00
1 parent e8d4a1a411
commit 964b138c3d
2 files changed
+26 -5

No files matched your search

+6 -1
View File
@@ -530,10 +530,15 @@ fn is_retryable_registry_error(error: &ExecServerError) -> bool {
if error.is_connect() || error.is_timeout()
) || matches!(
error,
ExecServerError::EnvironmentRegistryHttp { status, .. }
ExecServerError::EnvironmentRegistryHttp { status, code, .. }
if status.is_server_error()
|| *status == reqwest::StatusCode::REQUEST_TIMEOUT
|| *status == reqwest::StatusCode::TOO_MANY_REQUESTS
// TODO: Replace this coarse retry with an explicit registry/presence
// recovery FSM so `environment_offline` is retried only while the
// executor is expected to reconnect.
|| (*status == reqwest::StatusCode::CONFLICT
&& code.as_deref() == Some("environment_offline"))
)
}