Skip to content

Commit 54d6bb5

Browse files
authored
Update retry-interceptor warning message (#2709)
1 parent dbb0171 commit 54d6bb5

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

crates/chat-cli/src/api_client/delay_interceptor.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ use crossterm::{
1919
style,
2020
};
2121

22+
use crate::api_client::MAX_RETRY_DELAY_DURATION;
23+
2224
#[derive(Debug, Clone)]
2325
pub struct DelayTrackingInterceptor {
2426
minor_delay_threshold: Duration,
@@ -62,20 +64,16 @@ impl Intercept for DelayTrackingInterceptor {
6264
let now = Instant::now();
6365

6466
if let Some(last_attempt_time) = cfg.load::<LastAttemptTime>() {
65-
let delay = now.duration_since(last_attempt_time.0);
67+
let delay = now.duration_since(last_attempt_time.0).min(MAX_RETRY_DELAY_DURATION);
6668

6769
if delay >= self.major_delay_threshold {
6870
Self::print_warning(format!(
69-
"Auto Retry #{} delayed by {:.1}s. Service is under heavy load - consider switching models.",
71+
"Retry #{}, retrying within {:.1}s..",
7072
attempt_number,
71-
delay.as_secs_f64()
73+
MAX_RETRY_DELAY_DURATION.as_secs_f64()
7274
));
7375
} else if delay >= self.minor_delay_threshold {
74-
Self::print_warning(format!(
75-
"Auto Retry #{} delayed by {:.1}s due to transient issues.",
76-
attempt_number,
77-
delay.as_secs_f64()
78-
));
76+
Self::print_warning(format!("Retry #{}, retrying within 5s..", attempt_number,));
7977
}
8078
}
8179

crates/chat-cli/src/api_client/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ pub const X_AMZN_CODEWHISPERER_OPT_OUT_HEADER: &str = "x-amzn-codewhisperer-opto
7272
// TODO(bskiser): confirm timeout is updated to an appropriate value?
7373
const DEFAULT_TIMEOUT_DURATION: Duration = Duration::from_secs(60 * 5);
7474

75+
pub const MAX_RETRY_DELAY_DURATION: Duration = Duration::from_secs(10);
76+
7577
#[derive(Clone, Debug)]
7678
pub struct ModelListResult {
7779
pub models: Vec<Model>,
@@ -616,7 +618,7 @@ fn timeout_config(database: &Database) -> TimeoutConfig {
616618
fn retry_config() -> RetryConfig {
617619
RetryConfig::adaptive()
618620
.with_max_attempts(3)
619-
.with_max_backoff(Duration::from_secs(10))
621+
.with_max_backoff(MAX_RETRY_DELAY_DURATION)
620622
}
621623

622624
pub fn stalled_stream_protection_config() -> StalledStreamProtectionConfig {

0 commit comments

Comments
 (0)