Dealing with bot failures

This commit is contained in:
Timmy
2026-06-29 15:34:14 +01:00
parent b662a7da95
commit 75f41088b1
2 changed files with 34 additions and 8 deletions
@@ -210,6 +210,17 @@ pub(in crate::chat::transport::matrix::bot) async fn handle_message(
// Persist to disk so history survives server restarts.
save_history(&ctx.services.project_root, &guard);
} else {
// Clear session_id on error so a poisoned session (e.g. pending
// tool call with no response) doesn't cause a crash loop on resume.
let mut guard = ctx.history.lock().await;
if let Some(conv) = guard.get_mut(&room_id)
&& conv.session_id.is_some()
{
slog!("[matrix-bot] clearing session_id after error to prevent crash loop");
conv.session_id = None;
save_history(&ctx.services.project_root, &guard);
}
}
}