aKode fase 5: test e snapshot adeguati alla rinomina, 429 distinto (ProviderRateLimited), cargo fmt dopo il cambio dei prefissi

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-11 12:47:01 +01:00
parent 8b73331037
commit ad43f9281a
919 changed files with 2358 additions and 2430 deletions

View File

@@ -50,7 +50,11 @@ pub(crate) fn rate_limit_delay(advised: Option<Duration>, retry_count: u64) -> D
}
/// Message shown in the UI while waiting out a provider rate limit.
pub(crate) fn rate_limit_wait_message(delay: Duration, retry_count: u64, max_retries: u64) -> String {
pub(crate) fn rate_limit_wait_message(
delay: Duration,
retry_count: u64,
max_retries: u64,
) -> String {
let seconds = delay.as_secs_f64().ceil().max(1.0) as u64;
format!("Limite del provider raggiunto, riprovo tra {seconds} s ({retry_count}/{max_retries})")
}
@@ -118,7 +122,7 @@ pub(crate) async fn handle_response_stream_error(
ResponsesStreamRequest::RemoteCompactionV2 => RetryOperation::RemoteCompactionV2,
};
let retry_count = retry_state.retries.saturating_add(1);
if let CodexErrorDetails::RateLimitExceeded(message) = err.details() {
if let CodexErrorDetails::ProviderRateLimited(message) = err.details() {
let advised = err.server_retry_delay();
if advised.is_some_and(|delay| delay > LONG_WINDOW_RATE_LIMIT) {
return Err(CodexErr::new(
@@ -137,7 +141,14 @@ pub(crate) async fn handle_response_stream_error(
}
let delay = rate_limit_delay(advised, retry_count);
retry_state.retries = retry_count;
log_retry(request, turn_context, &err, retry_count, max_rate_limit_retries, delay);
log_retry(
request,
turn_context,
&err,
retry_count,
max_rate_limit_retries,
delay,
);
sess.notify_stream_error(
turn_context,
rate_limit_wait_message(delay, retry_count, max_rate_limit_retries),
@@ -285,7 +296,10 @@ mod rate_limit_tests {
#[test]
fn rate_limit_waits_follow_advice_and_are_capped() {
assert_eq!(rate_limit_delay(Some(Duration::from_secs(7)), 1), Duration::from_secs(7));
assert_eq!(
rate_limit_delay(Some(Duration::from_secs(7)), 1),
Duration::from_secs(7)
);
assert_eq!(
rate_limit_delay(Some(Duration::from_secs(600)), 1),
MAX_RATE_LIMIT_WAIT