mirror of
https://github.com/openai/codex.git
synced 2026-11-21 22:50:37 +00:00
Treat model-not-found provider errors as terminal failures (#56445)
## Why Provider errors with code `model_not_found` should end the turn immediately and preserve the provider's message instead of triggering retries. ## What changed - Recognize `model_not_found` in HTTP 400, 403, and 404 responses and in streamed `error` and `response.failed` events. - Preserve the provider message and any available HTTP status, and expose `modelNotFound` through the app-server protocol and generated schemas and SDK types. ## Testing Add coverage for HTTP classification, statusless stream errors, and terminal failures without retries across HTTP, SSE, and WebSocket responses. Verify that `thread/read` preserves the error reported by the live notification. GitOrigin-RevId: 88f824ac03c8c9669915b1e40c67b76c08326fbe
This commit is contained in:
@@ -125,31 +125,49 @@ async fn http_retry_deadline_survives_mapping_and_respects_terminal_errors() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn map_api_error_distinguishes_capacity_from_slow_down() {
|
||||
for (code, expected, retryable) in [
|
||||
fn map_http_error_classifies_provider_codes() {
|
||||
use CodexErrorInfo::ModelNotFound;
|
||||
|
||||
for (status, code, expected, retryable) in [
|
||||
(
|
||||
503,
|
||||
"server_is_overloaded",
|
||||
CodexErrorInfo::ServerOverloaded,
|
||||
false,
|
||||
),
|
||||
("slow_down", CodexErrorInfo::RateLimitExceeded, true),
|
||||
(503, "slow_down", CodexErrorInfo::RateLimitExceeded, true),
|
||||
(
|
||||
503,
|
||||
"unknown_error",
|
||||
CodexErrorInfo::HttpConnectionFailed {
|
||||
http_status_code: Some(503),
|
||||
},
|
||||
true,
|
||||
),
|
||||
(400, "model_not_found", ModelNotFound, false),
|
||||
(403, "model_not_found", ModelNotFound, false),
|
||||
(404, "model_not_found", ModelNotFound, false),
|
||||
(
|
||||
404,
|
||||
"resource_not_found",
|
||||
CodexErrorInfo::HttpConnectionFailed {
|
||||
http_status_code: Some(404),
|
||||
},
|
||||
true,
|
||||
),
|
||||
] {
|
||||
let err = map_api_error(ApiError::Transport(TransportError::Http {
|
||||
retry_after: None,
|
||||
status: http::StatusCode::SERVICE_UNAVAILABLE,
|
||||
status: http::StatusCode::from_u16(status).unwrap(),
|
||||
url: None,
|
||||
headers: None,
|
||||
body: Some(
|
||||
serde_json::json!({"error": {"code": code, "message": "retry later"}}).to_string(),
|
||||
),
|
||||
}));
|
||||
if expected == ModelNotFound {
|
||||
assert_eq!(err.http_status_code_value(), Some(status));
|
||||
}
|
||||
assert_eq!(
|
||||
(
|
||||
err.to_codex_protocol_error(),
|
||||
|
||||
Reference in New Issue
Block a user