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:
Charlie Marsh
2026-10-23 11:43:14 +00:00
committed by copyberry
parent ca9d103f39
commit 60adfa8513
39 changed files with 190 additions and 67 deletions
@@ -2,7 +2,7 @@
//! Only rate-limit codes derive retry delays from plaintext messages.
use crate::error::ApiError;
use crate::error::parse_flex_unavailable;
use crate::error::parse_terminal_provider_error;
use crate::responses_headers::json_headers_to_http_headers;
use codex_http_client::RetryAfter;
use codex_protocol::protocol::MisalignmentErrorDetails;
@@ -29,7 +29,7 @@ pub(super) fn parse_failed_response(response: Option<Value>) -> ApiError {
.and_then(|error| error.get("headers"))
.and_then(Value::as_object)
.and_then(|headers| RetryAfter::from_headers(&json_headers_to_http_headers(headers)));
if let Some(error) = error.and_then(parse_flex_unavailable) {
if let Some(error) = parse_terminal_provider_error(error, /*status*/ None) {
return error;
}
let Some(error) = error.and_then(|error| serde_json::from_value::<Error>(error.clone()).ok())