mirror of
https://github.com/openai/codex.git
synced 2026-11-08 20:40:33 +00:00
Treat incomplete responses as terminal errors (#53451)
## Why Incomplete responses such as `max_output_tokens` were classified as stream errors, allowing retries and compaction model fallback after the response had hit its output limit. ## What changed Introduce `ResponseIncomplete` errors that preserve the server-provided reason and stop stream processing immediately. Make these errors non-retryable and stop compaction without falling back to the selected model. Record incomplete responses separately in sampler failure metrics. ## Testing Add regression tests that verify incomplete responses surface a terminal error without retries over SSE and WebSocket, and that compaction stops without retrying or switching models for both local and remote compaction. GitOrigin-RevId: 6e107d441b9bf03fa47ea47b88eeb94b71a9f729
This commit is contained in:
@@ -429,8 +429,9 @@ pub fn process_responses_event(
|
||||
return Err(ResponsesEventError::Api(ApiError::ContentFilter));
|
||||
}
|
||||
if reason != "interrupted" {
|
||||
let message = format!("Incomplete response returned, reason: {reason}");
|
||||
return Err(ResponsesEventError::Api(ApiError::Stream(message)));
|
||||
return Err(ResponsesEventError::Api(ApiError::ResponseIncomplete(
|
||||
reason.to_string(),
|
||||
)));
|
||||
}
|
||||
}
|
||||
if let Some(resp_val) = event.response {
|
||||
@@ -639,7 +640,10 @@ async fn process_sse_with_treatment(
|
||||
Ok(None) => {}
|
||||
Err(error) => {
|
||||
let error = error.into_api_error();
|
||||
if matches!(error, ApiError::FlexUnavailable) {
|
||||
if matches!(
|
||||
error,
|
||||
ApiError::FlexUnavailable | ApiError::ResponseIncomplete(_)
|
||||
) {
|
||||
let _ = tx_event.send(Err(error)).await;
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user