From 2e30a84c68e9302348eb38712c7ebfd3b9e3bc87 Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Thu, 17 Jul 2025 19:53:35 -0700 Subject: [PATCH] review --- codex-rs/core/src/client.rs | 1 + codex-rs/core/src/codex.rs | 1 - codex-rs/core/src/model_provider_info.rs | 10 +++++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/codex-rs/core/src/client.rs b/codex-rs/core/src/client.rs index 4542e1f14c..b2e2c7c3cb 100644 --- a/codex-rs/core/src/client.rs +++ b/codex-rs/core/src/client.rs @@ -201,6 +201,7 @@ impl ModelClient { } } } + pub fn get_provider(&self) -> ModelProviderInfo { self.provider.clone() } diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index 531e6364f9..787fca5a55 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -1203,7 +1203,6 @@ async fn try_run_turn( } } } - // unreachable: loop only exits via return statements above } async fn handle_response_item( diff --git a/codex-rs/core/src/model_provider_info.rs b/codex-rs/core/src/model_provider_info.rs index ffae250f8d..d51f1521b4 100644 --- a/codex-rs/core/src/model_provider_info.rs +++ b/codex-rs/core/src/model_provider_info.rs @@ -17,6 +17,9 @@ use crate::openai_api_key::get_openai_api_key; /// Value for the `OpenAI-Originator` header that is sent with requests to /// OpenAI. const OPENAI_ORIGINATOR_HEADER: &str = "codex_cli_rs"; +const OPENAI_STREAM_IDLE_TIMEOUT_MS: u64 = 300_000; +const OPENAI_STREAM_MAX_RETRIES: u64 = 10; +const OPENAI_REQUEST_MAX_RETRIES: u64 = 4; /// Wire protocol that the provider speaks. Most third-party services only /// implement the classic OpenAI Chat Completions JSON schema, whereas OpenAI @@ -175,19 +178,20 @@ impl ModelProviderInfo { /// Effective maximum number of request retries for this provider. pub fn request_max_retries(&self) -> u64 { - self.request_max_retries.unwrap_or(4) + self.request_max_retries + .unwrap_or(OPENAI_REQUEST_MAX_RETRIES) } /// Effective maximum number of stream reconnection attempts for this provider. pub fn stream_max_retries(&self) -> u64 { - self.stream_max_retries.unwrap_or(10) + self.stream_max_retries.unwrap_or(OPENAI_STREAM_MAX_RETRIES) } /// Effective idle timeout for streaming responses. pub fn stream_idle_timeout(&self) -> Duration { self.stream_idle_timeout_ms .map(Duration::from_millis) - .unwrap_or(Duration::from_millis(300_000)) + .unwrap_or(Duration::from_millis(OPENAI_STREAM_IDLE_TIMEOUT_MS)) } }