mirror of
https://github.com/openai/codex.git
synced 2026-11-20 22:40:37 +00:00
Distinguish policy-restricted capacity failures from server overloads (#57452)
## What changed - Recognize `policy_capacity_unavailable` in HTTP and streaming API errors and expose it as `policyCapacityUnavailable` through the app-server protocol and generated bindings. - Display “Policy-restricted capacity is unavailable. Please try again later.” while preserving overload retry behavior based on `Retry-After`. - Handle the new error in TUI overload rendering, reviewer retries, and error telemetry. ## Testing Add coverage for HTTP and streaming error classification, retry advice, WebSocket terminal error attribution, protocol serialization, and TUI rendering with and without an upstream message. GitOrigin-RevId: 1b9536fba1e11cc891dcf689aee35410d82f5412
This commit is contained in:
committed by
copyberry
parent
824b7666fb
commit
6a6e2fb1f0
@@ -24,6 +24,7 @@ pub fn map_api_error(err: ApiError) -> CodexErr {
|
||||
ApiError::Retryable { retry_after, .. }
|
||||
| ApiError::RateLimitExceeded { retry_after, .. }
|
||||
| ApiError::ServerOverloaded { retry_after }
|
||||
| ApiError::PolicyCapacityUnavailable { retry_after }
|
||||
| ApiError::Transport(TransportError::Http { retry_after, .. }) => *retry_after,
|
||||
ApiError::Transport(_)
|
||||
| ApiError::Api { .. }
|
||||
@@ -64,6 +65,9 @@ fn map_api_error_details(err: ApiError) -> CodexErr {
|
||||
CodexErr::new(CodexErrorDetails::ResponseIncomplete(incomplete))
|
||||
}
|
||||
ApiError::ServerOverloaded { .. } => CodexErr::ServerOverloaded,
|
||||
ApiError::PolicyCapacityUnavailable { .. } => {
|
||||
CodexErr::new(CodexErrorDetails::PolicyCapacityUnavailable)
|
||||
}
|
||||
ApiError::FlexUnavailable => CodexErr::new(CodexErrorDetails::FlexUnavailable),
|
||||
ApiError::Api { status, message } => {
|
||||
let user_message = api_error_user_message(status, &message);
|
||||
@@ -115,6 +119,9 @@ fn map_api_error_details(err: ApiError) -> CodexErr {
|
||||
&& let Some(error) = provider_error
|
||||
{
|
||||
match error.get("code").and_then(Value::as_str) {
|
||||
Some("policy_capacity_unavailable") => {
|
||||
return CodexErr::new(CodexErrorDetails::PolicyCapacityUnavailable);
|
||||
}
|
||||
Some("server_is_overloaded") => return CodexErr::ServerOverloaded,
|
||||
Some("slow_down") => {
|
||||
return CodexErr::new(CodexErrorDetails::RateLimitExceeded(
|
||||
|
||||
Reference in New Issue
Block a user