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",