hank9999 commited on
Commit
eec4f69
·
1 Parent(s): 55e7e05

fix: 429 不应该禁用或切换凭据

Browse files
Files changed (1) hide show
  1. src/kiro/provider.rs +19 -0
src/kiro/provider.rs CHANGED
@@ -224,6 +224,25 @@ impl KiroProvider {
224
  anyhow::bail!("{} API 请求失败: {} {}", api_type, status, body);
225
  }
226
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  // 其他错误 - 记录失败并可能重试(使用绑定的 id)
228
  let body = response.text().await.unwrap_or_default();
229
  tracing::warn!(
 
224
  anyhow::bail!("{} API 请求失败: {} {}", api_type, status, body);
225
  }
226
 
227
+ // 429 Too Many Requests - 限流错误,不算凭据错误,重试但不禁用凭据
228
+ if status.as_u16() == 429 {
229
+ let body = response.text().await.unwrap_or_default();
230
+ tracing::warn!(
231
+ "API 请求被限流(尝试 {}/{}): {} {}",
232
+ attempt + 1,
233
+ max_retries,
234
+ status,
235
+ body
236
+ );
237
+ last_error = Some(anyhow::anyhow!(
238
+ "{} API 请求被限流: {} {}",
239
+ if is_stream { "流式" } else { "非流式" },
240
+ status,
241
+ body
242
+ ));
243
+ continue;
244
+ }
245
+
246
  // 其他错误 - 记录失败并可能重试(使用绑定的 id)
247
  let body = response.text().await.unwrap_or_default();
248
  tracing::warn!(