Fix UTF-8 panics and inconsistent retry logic

- Fix 7 UTF-8 byte slicing panics that crash on multi-byte characters:
  - acd.rs: extract_topic_from_text() [..50] slice
  - streaming.rs: log_stream_error() [..500] slice
  - tools/acd.rs: rehydrate message truncation [..2000] slice
  - history.rs: git commit message truncation [..69] slice
  - planner.rs: commit summary/description truncation [..69] slices
  - llm.rs: requirements summary line truncation [..117] slice

- All now use chars().count() and chars().take(N).collect() for
  UTF-8 safe truncation

- Fix inconsistent retry logic in task_execution.rs:
  - Previously only retried on Timeout errors
  - Now retries on ALL recoverable errors (rate limits, network,
    server errors, model busy, token limits, context length)
  - Added error-specific base delays (rate limit: 5s, server: 2s, etc.)
  - Added exponential backoff with ±20% jitter
  - Consistent with autonomous mode retry behavior
This commit is contained in:
Dhanji R. Prasanna
2026-01-13 05:49:45 +05:30
parent 6f50d01ab6
commit f30f145c85
9 changed files with 64 additions and 35 deletions

View File

@@ -519,8 +519,9 @@ pub fn parse_commit_message(response: &str) -> (String, String) {
}
// Ensure summary is max 72 chars
if summary.len() > 72 {
summary = format!("{}...", &summary[..69]);
if summary.chars().count() > 72 {
let chars: String = summary.chars().take(69).collect();
summary = format!("{}...", chars);
}
// Ensure description lines are max 72 chars
@@ -528,8 +529,9 @@ pub fn parse_commit_message(response: &str) -> (String, String) {
.lines()
.take(10) // Max 10 lines
.map(|line| {
if line.len() > 72 {
format!("{}...", &line[..69])
if line.chars().count() > 72 {
let chars: String = line.chars().take(69).collect();
format!("{}...", chars)
} else {
line.to_string()
}