feat: enhance command classification and error handling; improve process checks and credential security
This commit is contained in:
+11
-2
@@ -139,7 +139,11 @@ impl LlmClient {
|
||||
Ok((msg, usage)) => return Ok((msg, usage)),
|
||||
Err(e) => {
|
||||
let err_str = e.to_string();
|
||||
let is_auth_error = err_str.contains("API error 401") || err_str.contains("API error 403");
|
||||
let err_lower = err_str.to_lowercase();
|
||||
let is_auth_error = err_str.contains("401") || err_str.contains("403")
|
||||
|| err_lower.contains("unauthorized")
|
||||
|| err_lower.contains("forbidden")
|
||||
|| err_lower.contains("authentication failed");
|
||||
if attempt >= max_retries || is_auth_error {
|
||||
return Err(e);
|
||||
}
|
||||
@@ -191,7 +195,11 @@ impl LlmClient {
|
||||
Ok(result) => return Ok(result),
|
||||
Err(e) => {
|
||||
let err_str = e.to_string();
|
||||
let is_auth_error = err_str.contains("API error 401") || err_str.contains("API error 403");
|
||||
let err_lower = err_str.to_lowercase();
|
||||
let is_auth_error = err_str.contains("401") || err_str.contains("403")
|
||||
|| err_lower.contains("unauthorized")
|
||||
|| err_lower.contains("forbidden")
|
||||
|| err_lower.contains("authentication failed");
|
||||
if started || attempt >= max_retries || is_auth_error {
|
||||
return Err(e);
|
||||
}
|
||||
@@ -281,6 +289,7 @@ impl LlmClient {
|
||||
}
|
||||
StreamEvent::Done => {
|
||||
turn.apply_event(&event);
|
||||
turn.done_received = true;
|
||||
return Ok((turn.build_assistant_message(), usage));
|
||||
}
|
||||
_ => turn.apply_event(&event),
|
||||
|
||||
Reference in New Issue
Block a user