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:
Steve Coffey authored and copyberry committed 2026-08-26 17:45:42 +00:00
1 parent 7625bd5665
commit e0c727de04
38 files changed
+198 -26

No files matched your search

+10 -4
View File
@@ -587,14 +587,17 @@ async fn compact_v2_stream_failure_without_retry_after_exhausts_stream_retries()
match wait_for_event(&test.codex, |_| true).await {
EventMsg::Error(error) => {
error_events += 1;
assert_eq!(error.codex_error_info, Some(CodexErrorInfo::Other));
assert_eq!(
error.codex_error_info,
Some(CodexErrorInfo::RateLimitExceeded)
);
assert!(error.message.contains("Rate limit exceeded."));
}
EventMsg::StreamError(_) => stream_error_events += 1,
EventMsg::TurnComplete(event) => {
assert_eq!(
event.error.and_then(|error| error.codex_error_info),
Some(CodexErrorInfo::Other)
Some(CodexErrorInfo::RateLimitExceeded)
);
break;
}
@@ -1001,14 +1004,17 @@ async fn sse_failure_without_retry_after_exhausts_stream_retries() -> Result<()>
match wait_for_event(&test.codex, |_| true).await {
EventMsg::Error(error) => {
error_events += 1;
assert_eq!(error.codex_error_info, Some(CodexErrorInfo::Other));
assert_eq!(
error.codex_error_info,
Some(CodexErrorInfo::RateLimitExceeded)
);
assert!(error.message.contains("Rate limit exceeded."));
}
EventMsg::StreamError(_) => stream_error_events += 1,
EventMsg::TurnComplete(event) => {
assert_eq!(
event.error.and_then(|error| error.codex_error_info),
Some(CodexErrorInfo::Other)
Some(CodexErrorInfo::RateLimitExceeded)
);
break;
}