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

@@ -11,16 +11,16 @@ use crate::protocol::RateLimitReachedType;
use crate::protocol::RateLimitSnapshot;
use crate::protocol::TokenUsage;
use crate::protocol::TruncationPolicy;
use chrono::DateTime;
use chrono::Datelike;
use chrono::Local;
use chrono::Utc;
use akode_async_utils::CancelErr;
use akode_async_utils::backoff;
use akode_http_client::HttpError;
use akode_http_client::RetryAfter;
use akode_utils_string::truncate_middle_chars;
use akode_utils_string::truncate_middle_with_token_budget;
use chrono::DateTime;
use chrono::Datelike;
use chrono::Local;
use chrono::Utc;
use http::StatusCode;
use serde_json;
use std::fmt;
@@ -123,13 +123,16 @@ pub enum CodexErrorDetails {
/// A retryable upstream rate limit received inside the response stream.
#[error("rate limit exceeded: {0}")]
RateLimitExceeded(String),
/// HTTP 429 from the model provider: back off and retry, more patiently than other failures.
#[error("Limite del provider raggiunto: {0}")]
ProviderRateLimited(String),
/// The provider's daily (or otherwise long-window) request allowance is used up; retrying
/// within the turn cannot succeed.
#[error("Limite giornaliero del provider esaurito. {0}")]
ProviderDailyLimitExhausted(String),
// The iOS input-limit classifier matches this message's ASCII prefix.
#[error(
"Codex ran out of room in the model's context window. Start a new thread or clear earlier history before retrying."
"aKode ran out of room in the model's context window. Start a new thread or clear earlier history before retrying."
)]
ContextWindowExceeded,
#[error("no thread with id: {0}")]
@@ -475,6 +478,7 @@ impl CodexErr {
CodexErrorDetails::Stream(..)
| CodexErrorDetails::ContentFilter
| CodexErrorDetails::RateLimitExceeded(_)
| CodexErrorDetails::ProviderRateLimited(_)
| CodexErrorDetails::Timeout
| CodexErrorDetails::RequestTimeout
| CodexErrorDetails::UnexpectedStatus(_)
@@ -522,7 +526,9 @@ impl CodexErr {
match &self.details {
CodexErrorDetails::ContextWindowExceeded => CodexErrorInfo::ContextWindowExceeded,
CodexErrorDetails::SessionBudgetExceeded => CodexErrorInfo::SessionBudgetExceeded,
CodexErrorDetails::RateLimitExceeded(_) => CodexErrorInfo::RateLimitExceeded,
CodexErrorDetails::RateLimitExceeded(_) | CodexErrorDetails::ProviderRateLimited(_) => {
CodexErrorInfo::RateLimitExceeded
}
CodexErrorDetails::UsageLimitReached(_)
| CodexErrorDetails::QuotaExceeded
| CodexErrorDetails::ProviderDailyLimitExhausted(_)