修复: run_command 空路径报错 + 隧道日志洪水 + 启动残留清理
- tool_registry: run_command working_dir 空字符串 "" → None,修 Windows os error 123 - lib: tunnel subscriber 从频率压制(suppress_until)改为连接状态感知(is_connected), 断开时静默丢弃事件,重连后恢复透传,记 INFO 状态变迁(治本) - conversation_repo: 新增 cleanup_stale_pending(),超 24h 残留 pending 标记 interrupted - restore: 启动时先清理过期 pending 再恢复审批 - state: 实现 cleanup_orphan_pending_messages(),启动时清理对应已决/超时 tool 的 __PENDING__ 占位消息
This commit is contained in:
@@ -264,6 +264,25 @@ impl AiToolExecutionRepo {
|
||||
.map_err(storage_err)?
|
||||
}
|
||||
|
||||
/// 清理超期的残留 pending 工具调用(旧会话遗留)。
|
||||
///
|
||||
/// `max_age_secs`: 超过此秒数的 pending 记录被标记为 interrupted(不硬删,保留审计痕迹)。
|
||||
pub async fn cleanup_stale_pending(&self, max_age_secs: u64) -> Result<u64> {
|
||||
let conn = self.conn.clone();
|
||||
let cutoff_ms = (df_types::now_millis() as i64 - (max_age_secs as i64 * 1000)).to_string();
|
||||
let affected = tokio::task::spawn_blocking(move || {
|
||||
let guard = conn.blocking_lock();
|
||||
guard.execute(
|
||||
"UPDATE ai_tool_executions SET status = 'interrupted' \
|
||||
WHERE status = 'pending' AND CAST(requested_at AS INTEGER) < ?1",
|
||||
params![cutoff_ms],
|
||||
).map_err(storage_err)
|
||||
})
|
||||
.await
|
||||
.map_err(storage_err)??;
|
||||
Ok(affected as u64)
|
||||
}
|
||||
|
||||
/// 审批历史面板分页查询:按 requested_at 倒序(最新在前),limit 默认 50。
|
||||
///
|
||||
/// 与 list_pending 同理走专用 SELECT,绕过通用 query 宏(后者硬编码
|
||||
|
||||
Reference in New Issue
Block a user