From f23c3066c898d7eb1e1637b7eefe640808ba4234 Mon Sep 17 00:00:00 2001 From: pakrym-oai Date: Thu, 7 Aug 2025 10:46:43 -0700 Subject: [PATCH] Add capacity error (#1947) --- codex-rs/core/src/client.rs | 4 ++++ codex-rs/core/src/error.rs | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/codex-rs/core/src/client.rs b/codex-rs/core/src/client.rs index 723247d2..34aecad1 100644 --- a/codex-rs/core/src/client.rs +++ b/codex-rs/core/src/client.rs @@ -271,6 +271,10 @@ impl ModelClient { } if attempt > max_retries { + if status == StatusCode::INTERNAL_SERVER_ERROR { + return Err(CodexErr::InternalServerError); + } + return Err(CodexErr::RetryLimit(status)); } diff --git a/codex-rs/core/src/error.rs b/codex-rs/core/src/error.rs index 1f283346..f6394b71 100644 --- a/codex-rs/core/src/error.rs +++ b/codex-rs/core/src/error.rs @@ -68,6 +68,11 @@ pub enum CodexErr { #[error("Usage not included with the plan")] UsageNotIncluded, + #[error( + "We’re currently experiencing high demand, which may cause temporary errors. We’re adding capacity in East and West Europe to restore normal service." + )] + InternalServerError, + /// Retry limit exceeded. #[error("exceeded retry limit, last status: {0}")] RetryLimit(StatusCode),