From da898490fcc7e75661c367f6a441798a0ce0eb95 Mon Sep 17 00:00:00 2001 From: "Adam Perry @ OpenAI" Date: Fri, 14 Aug 2026 16:18:21 +0000 Subject: [PATCH] Make unbounded connection retries configurable (#38601) ## What changed - Add the stable, default-enabled `unbounded_connection_retries` feature. - Require the feature for unbounded sampling retries after connection failures. When disabled, connection failures use the existing bounded retry and transport fallback path. - Expose the feature in the generated configuration schema. GitOrigin-RevId: bd80d02ef065ba924f805c29b639752fc817ed64 --- codex-rs/core/config.schema.json | 6 ++++++ codex-rs/core/src/responses_retry.rs | 7 ++++++- codex-rs/features/src/lib.rs | 8 ++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/codex-rs/core/config.schema.json b/codex-rs/core/config.schema.json index 4aa6f704ac..e39dc1fabe 100644 --- a/codex-rs/core/config.schema.json +++ b/codex-rs/core/config.schema.json @@ -777,6 +777,9 @@ "unavailable_dummy_tools": { "type": "boolean" }, + "unbounded_connection_retries": { + "type": "boolean" + }, "undo": { "type": "boolean" }, @@ -5434,6 +5437,9 @@ "unavailable_dummy_tools": { "type": "boolean" }, + "unbounded_connection_retries": { + "type": "boolean" + }, "undo": { "type": "boolean" }, diff --git a/codex-rs/core/src/responses_retry.rs b/codex-rs/core/src/responses_retry.rs index cfc68ccf73..178c13df49 100644 --- a/codex-rs/core/src/responses_retry.rs +++ b/codex-rs/core/src/responses_retry.rs @@ -7,6 +7,7 @@ use crate::session::session::Session; use crate::session::turn_context::TurnContext; use crate::util::backoff; use codex_client::RetryOperation; +use codex_features::Feature; use codex_protocol::error::CodexErr; use codex_protocol::error::CodexErrorDetails; use codex_protocol::protocol::EventMsg; @@ -54,7 +55,11 @@ pub(crate) async fn handle_retryable_response_stream_error( ResponsesStreamRequest::RemoteCompactionV2 => RetryOperation::RemoteCompactionV2, }; - if matches!(request, ResponsesStreamRequest::Sampling) + if turn_context + .config + .features + .enabled(Feature::UnboundedConnectionRetries) + && matches!(request, ResponsesStreamRequest::Sampling) && matches!(err.details(), CodexErrorDetails::ConnectionFailed(_)) && !turn_context.session_source.is_internal() && !turn_context.provider.info().is_amazon_bedrock() diff --git a/codex-rs/features/src/lib.rs b/codex-rs/features/src/lib.rs index 5e47dcbcb7..22f1d8755b 100644 --- a/codex-rs/features/src/lib.rs +++ b/codex-rs/features/src/lib.rs @@ -157,6 +157,8 @@ pub enum Feature { Chronicle, /// Compress request bodies (zstd) when sending streaming requests to codex-backend. EnableRequestCompression, + /// Keep active sampling turns alive until a failed network connection recovers. + UnboundedConnectionRetries, /// Start the managed network proxy for sandboxed sessions. NetworkProxy, /// Respect host system proxy settings for Codex-owned network clients. @@ -1054,6 +1056,12 @@ pub const FEATURES: &[FeatureSpec] = &[ stage: Stage::Stable, default_enabled: true, }, + FeatureSpec { + id: Feature::UnboundedConnectionRetries, + key: "unbounded_connection_retries", + stage: Stage::Stable, + default_enabled: true, + }, FeatureSpec { id: Feature::NetworkProxy, key: "network_proxy",