| 1292 | } |
| 1293 | |
| 1294 | fn classify_tool_error(kind: Option<StreamToolErrorKind>, error: &str) -> ToolExecutionErrorKind { |
| 1295 | if let Some(kind) = kind { |
| 1296 | return match kind { |
| 1297 | StreamToolErrorKind::PermissionDenied => ToolExecutionErrorKind::PermissionDenied, |
| 1298 | StreamToolErrorKind::QuestionRejected => ToolExecutionErrorKind::QuestionRejected, |
| 1299 | StreamToolErrorKind::ExecutionError => ToolExecutionErrorKind::Other, |
| 1300 | }; |
| 1301 | } |
| 1302 | |
| 1303 | let lower = error.to_ascii_lowercase(); |
| 1304 | if lower.starts_with("permission denied:") || lower.contains("permission denied") { |
| 1305 | return ToolExecutionErrorKind::PermissionDenied; |
| 1306 | } |
| 1307 | if lower.starts_with("question rejected:") || lower.contains("question rejected") { |
| 1308 | return ToolExecutionErrorKind::QuestionRejected; |
| 1309 | } |
| 1310 | ToolExecutionErrorKind::Other |
| 1311 | } |
| 1312 | |
| 1313 | fn build_messages(system: &[String], user_messages: &[Message]) -> Vec<Message> { |
| 1314 | let mut messages: Vec<Message> = system.iter().map(|s| Message::system(s)).collect(); |