[ai] 持久化 deadline 覆盖整次交互:超过 30s 后工具结果/最终答案/轮次收尾同时失败,整轮对话丢失
Los mantenedores suelen responder en 8 días
@ambiguous-pointer ya está trabajando en esto.
Desde el 14/11/2026.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 45/100
Línea de trabajo
Start in ai/component/agent/react/react.go, where persistenceTimeout and persistCtx are created once per interaction, then follow persistenceContext in steps.go to the three writes: tool results, the final answer, and NextTurnForTurn. The fix proposed in the issue's solution comment should be checked against these call sites. Done means that a slow interaction (over 30s) still persists tool results and turn completion, and that a store failure on the final answer no longer hides the generated answer. Look for existing tests in the react package before changing behavior.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
概要
AI 助手的持久化 deadline 覆盖的是整次交互,而不是单次写入。一次交互很容易超过这个 deadline(多次模型调用 + 中间的工具调用),一旦超时,工具结果、最终答案、轮次收尾三处写库同时失败,整轮对话被 abort,该会话的下一个问题从零历史开始。
对用户的表现是:「AI 突然忘了我刚说过的话」,而且是在问题越多、工具越重的会话里越容易触发。
1. 问题
1.1 一个 deadline 被整个交互共享
ai/component/agent/react/react.go:
:76 const persistenceTimeout = 30 * time.Second
...
:337 persistCtx, persistCancel := context.WithTimeout(context.WithoutCancel(parent), persistenceTimeout)
:359 state := &interactionState{... persistCtx: persistCtx, persistCancel: persistCancel}
:362 ctx = context.WithValue(ctx, persistenceContextKey, persistCtx)
persistCtx 在交互开始时创建,30 秒后到期,并被注入整条交互链路的 context。
1.2 三个写库点全部使用这个共享 context
ai/component/agent/react/steps.go:
:291 func persistenceContext(ctx context.Context) context.Context { // 取回共享的 persistCtx
:231 ra.messageStore.AddHistoryToTurn(persistenceContext(ctx), access, s.Session, turnID, message) // ① 工具结果
:251 ra.messageStore.AddHistoryToTurn(persistenceContext(ctx), access, sessionID, turnID, message) // ② 最终答案
:252 return fmt.Errorf("failed to persist final answer: %w", err)
ai/component/agent/react/react.go:
:254 ra.messageStore.NextTurnForTurn(state.persistCtx, access, sessionID, state.turnID) // ③ 轮次收尾
interactionErr = fmt.Errorf("failed to complete turn: %w", err)
deadline 一到,① ② ③ 全部返回 context deadline exceeded:
- ① 工具结果丢失 → 下一轮上下文里没有工具输出;
- ② 最终答案写库失败 并向上返回错误 → 已经生成好的答案被整个隐藏,用户收到的是失败而不是回答;
- ③ 轮次收尾失败 → 该轮被 abort,下一次提问从空历史开始。
1.3 关键在于「答案已经生成成功了」
② 的失败发生在答案生成之后。当前实现把「存储暂时不健康」升级成了「用户拿不到回答」,这是错误的取舍。
2. 为什么重要
- 数据丢失:用户这一轮说过的话、Agent 调过的工具结果、最终答案,在这 30s 之后都不入库。
- 会话体验断裂:下一轮没有历史,模型看起来「失忆」,用户会重复描述已经给过的上下文。
- 可用性反噬:存储后端(MySQL/PG)稍有抖动,答案就消失——存储故障被放大成了产品故障。
- 触发条件不可控:交互耗时取决于模型输出长度和工具调用次数,用户无法预知;长问题 + 慢工具必然越界。
3. 证据
代码位置(ai 分支):
| 位置 | 内容 |
|---|---|
ai/component/agent/react/react.go:76 |
const persistenceTimeout = 30 * time.Second |
ai/component/agent/react/react.go:337 |
persistCtx, persistCancel := context.WithTimeout(context.WithoutCancel(parent), persistenceTimeout) |
ai/component/agent/react/react.go:359-362 |
persistCtx 存入 interactionState 并经 persistenceContextKey 注入交互 ctx |
ai/component/agent/react/steps.go:231 |
工具结果写入使用共享 ctx |
ai/component/agent/react/steps.go:251-252 |
最终答案写入使用共享 ctx,失败直接返回错误 |
ai/component/agent/react/react.go:254 |
轮次收尾使用 state.persistCtx |
关键点:persistCtx 的 deadline 是从交互开始计时,而它服务的写操作发生在交互的末尾。一次交互 = 若干次模型调用 + 中间的工具调用,中间任何一段慢都会让末尾的写操作落在 deadline 之外。
4. 影响范围
- 触发条件:单次交互耗时 > 30s(多轮工具调用、慢模型、慢存储都会叠加)。
- 受影响组件:
ai/component/agent/react的 ReAct 循环 +ai/store的会话持久化。 - 已有可用修复(尚未提交 PR):见本 Issue 的解决方案评论。
- Lenguaje dominante
- Go
- Estrellas
- 4.1k
- Forks
- 2.2k
- Merge medio
- 6 d 2 h
- PR fusionados (30 d)
- 4
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/dubbo-admin
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
apache/dubbo-admin#1659 ·
Los mantenedores suelen responder en 8 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
apache/dubbo-admin#1658 ·
Los mantenedores suelen responder en 8 días
-
Editing a tag rule in the UI form drops the addresses of its tagsPosiblemente ocupada @AsperforMias la tomó hace 7 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
apache/dubbo-admin#1649 ·
Los mantenedores suelen responder en 8 días
-
[Bug] Generic invoke does not propagate timeoutMs to Dubbo client, causing per-request timeout to fall back to 3sPosiblemente ocupada @dodjdnh la tomó hace 3 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
apache/dubbo-admin#1654 ·
Los mantenedores suelen responder en 8 días
-
Dificultad 3/5 Medio día Aptitud para principiantes 40/100
apache/dubbo-admin#1646 · 1 comentario ·
Los mantenedores suelen responder en 8 días
Todos los issues de apache/dubbo-admin
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
taskmanager: a failed v1alpha1 backup leaves the partial backup behindPosiblemente ocupada @arshil42 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
modelcontextprotocol/go-sdk#1557 ·
Los mantenedores suelen responder en 1 día
-
Packaging: support mise-en-placeAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100