修复: 工具执行无心跳致流中断误报

This commit is contained in:
2026-06-24 22:13:48 +08:00
parent 8df7e248b4
commit 93172a6844
3 changed files with 81 additions and 3 deletions

View File

@@ -60,6 +60,23 @@ export function onStreamTimeout(convId?: string) {
clearStreamWatchdog(convId)
return
}
// 兜底守卫(BUG-260624-03):工具执行中(running 卡)不计整流超时。
// 后端 execute_with_heartbeat(audit/mod.rs)已为工具执行补 30s AiHeartbeat,正常执行
// 不会到 130s 超时;到此且仍有 running 卡 = 心跳也丢失(老后端/provider 双重异常),
// 静默续等(reset 重计 130s)给工具完成/心跳恢复机会,不抛"工具已执行完成后续中断"误报。
// 注:真死锁(running 永驻)时续等会持续,但优于误报流中断(forceReset 致状态不一致);
// running 状态由后端 AiToolCallCompleted 驱动(非 ToolCard approving 计时器,那仅复位按钮 loading),
// 用户可手动 stop,且 A 心跳已覆盖正常执行,真死锁罕见。
for (let i = state.messages.length - 1; i >= 0; i--) {
const toolCalls = state.messages[i].toolCalls
if (!toolCalls) continue
for (let j = 0; j < toolCalls.length; j++) {
if (toolCalls[j].status === 'running') {
resetStreamWatchdog(convId)
return
}
}
}
// 卡死兜底走 guard 的 forceResetStreaming(复位 streaming + 清 currentText/queue + warn 日志)。
// TD-260621-01:携带 convId 时仅清该 conv 的 generatingConvs(per-conv);不传时全局兜底不动 Set。
forceResetStreaming('onStreamTimeout(130s 无数据)', convId)