ambiguous-pointer commented on issue #1645:
URL: https://github.com/apache/dubbo-admin/issues/1645#issuecomment-6877904696
## 已有 PR 在修同一处:#1617
**@Qiao-yq 的 #1617 已经实现了「每次写入独立有界 context」这一核心修正**,方法与本 Issue 描述的方案一致:
```go
func persistenceContext(ctx context.Context) (context.Context,
context.CancelFunc) {
// Persistence must outlive the model/tool execution deadline. Each
write
// receives a fresh bounded context instead of sharing the interaction's
// original 30-second lease.
return context.WithTimeout(context.WithoutCancel(ctx),
persistenceTimeout)
}
```
因此 fork 上的 `fix/ai-persistence-deadline` 分支**不必再作为竞争性 PR 提交**——重复提交只会让 #1617
的评审多一份噪音。本 Issue 转为跟踪 #1617 尚未覆盖的两个点。
## 其余相关 PR 的现状
同一批依赖链上的 PR(#1596 → #1608 → #1609 → #1610 → #1611 → #1615 →
#1617)目前都**仍然保留交互级 deadline**:
```go
persistCtx, persistCancel :=
context.WithTimeout(context.WithoutCancel(parent), persistenceTimeout)
```
它们新增的是 `CompleteInteraction`(把「交互完成」与「轮次推进」拆成两次写入),但 `state.persistCtx`
仍然是那个从交互开始计时的 30s context。**#1617 合并之前,本 Issue 描述的整轮丢失问题在这条链上依然存在**;若
#1611/#1615 先于 #1617 合入,deadline 问题会被带进 `ai` 分支。
## #1617 尚未覆盖的两点
### 1. 最终答案写库失败仍会中断整个交互
#1617 的 diff 里这一行保留原样:
```go
if err := ra.messageStore.AddHistoryToTurn(persistCtx, access, sessionID,
turnID, message); err != nil {
return fmt.Errorf("failed to persist final answer: %w", err)
}
```
deadline 修好之后,这条路径的**超时**场景会消失,但**存储后端故障**(连接池耗尽、慢查询、MySQL
短暂不可用)依然会让已经生成好的答案被整个隐藏——用户收到的是失败而不是回答。答案已经产出,存储不健康不该升级成产品故障。
建议改为:记录日志(`rt.GetLogger().Error(...)`),不再向上返回错误,轮次照常收尾。
### 2. 缺「交互长于写预算」的回归用例
`persistenceTimeout` 目前仍是 `const`,测试无法缩短它。要覆盖这个场景需要先改成 `var`,再补一个把预算调到极小、配合慢
store 的用例,断言长交互后工具结果与最终答案**仍被写入**、轮次**正常收尾**。
考虑到 #1617 已经在 `store_integration_test.go` 里补了不少用例,把 `persistenceTimeout` 改成
`var` 的改动很小,建议在 #1617 内一并完成;若评审意见倾向于保持 `const`,则本 Issue 继续跟踪该项。
## 建议的收口方式
- **deadline 修正**:认领 #1617,本 Issue 不再重复实现;
- **答案不中断交互 + 回归用例**:在 #1617 内一并处理,或由本 Issue 单独跟踪;
- 合并后,本 Issue 与 `fix/ai-persistence-deadline` 分支一并关闭。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]