mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Classify streaming rate-limit errors (#40931)
## What changed - Classify `response.failed` events with the `rate_limit_exceeded` code as a distinct retryable error while preserving any parsed retry delay. - Expose the error as `rateLimitExceeded` through the core protocol and app-server schemas after stream retries are exhausted. - Preserve the upstream message for TUI display while keeping it out of telemetry summaries. ## Testing - Cover SSE classification, retry metadata, protocol conversion and serialization, exhausted stream retries, telemetry redaction, and TUI rendering. GitOrigin-RevId: 02dab4d3477dcd7653a58c49c4bd38687a616579
This commit is contained in:
+5
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: tui/src/chatwidget/tests/app_server.rs
|
||||
expression: lines_to_single_string(&lines)
|
||||
---
|
||||
■ rate limit exceeded: Please try again in 10s.
|
||||
@@ -1,4 +1,6 @@
|
||||
use super::*;
|
||||
use codex_protocol::error::CodexErr;
|
||||
use codex_protocol::error::CodexErrorDetails;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
const SAFETY_BUFFERING_HEADER_TEXT: &str =
|
||||
@@ -1361,6 +1363,26 @@ async fn live_app_server_stream_recovery_restores_previous_status_header() {
|
||||
assert!(chat.status_state.retry_status_header.is_none());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn live_app_server_rate_limit_error_renders_upstream_message() {
|
||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
let error = CodexErr::from(CodexErrorDetails::RateLimitExceeded(
|
||||
"Please try again in 10s.".to_string(),
|
||||
));
|
||||
|
||||
handle_error(
|
||||
&mut chat,
|
||||
error.to_string(),
|
||||
Some(error.to_codex_protocol_error().into()),
|
||||
);
|
||||
|
||||
let lines = drain_insert_history(&mut rx)
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.collect::<Vec<_>>();
|
||||
assert_chatwidget_snapshot!("rate_limit_exceeded_error", lines_to_single_string(&lines));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn live_app_server_server_overloaded_error_renders_warning() {
|
||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
|
||||
Reference in New Issue
Block a user