修复: AI工具OOM/路径遍历+续跑锁收敛+UX交互批
This commit is contained in:
@@ -46,8 +46,10 @@ impl TokenAccumulator {
|
||||
/// 把单轮增量叠加到 DB 的 Option<i64> 字段(读旧值+增量,跨 loop 实例防覆盖)
|
||||
///
|
||||
/// 纯函数:抽自 save_conversation 的 token 累加逻辑,None 起始当作 0。
|
||||
/// saturating_add:长期对话累积接近 i64::MAX 时不再翻负,封顶在 i64::MAX(统计语义安全,
|
||||
/// 溢出回绕成负值会污染前端用量展示与计费/限额判定)。
|
||||
pub(crate) fn accumulate_tokens(old: Option<i64>, add: u32) -> Option<i64> {
|
||||
Some(old.unwrap_or(0) + add as i64)
|
||||
Some(old.unwrap_or(0).saturating_add(add as i64))
|
||||
}
|
||||
|
||||
/// 持久化截断阈值:超过此长度的消息 content 落库前截断头尾各保 HEAD/TAIL 字符。
|
||||
|
||||
Reference in New Issue
Block a user