Repository navigation
Replies: 2 comments
|
This is an independent confirmation of the exact mechanism reported in #2900 (divaliu1408) — two reporters, same log shape, same repair gap, same fix family. That convergence is itself worth flagging for the maintainers: the mechanism is now doubly confirmed by separate diagnosis chains, so the fix has two independent signatures behind it. 1. Mechanism identity: balanced-but-dangling (corruption family #9). Your log shape matches #2900's exactly: 2. Your fix suggestions are correct and map to real code. Reusing the synthetic 3. Your scheduler angle is the useful addition. #2900's crash was in the tool-execution path; yours is a scheduler crash (the duplicate-module context). Different crash sites, same consequence — which is precisely why fix direction (b) (serialize-time pairing check) matters most: it protects all future crash paths, not just the two known ones. The family is up to 10 reports now (#1333/#1452/#1497/#1473/#1586/#2167/#2342/#2839/#2900 + yours), with mechanism #9 now carrying two independent reports. 4. On #2660 — the crash cause itself now has two victims. MrYangyt's "我也遇到了这个问题" confirms the 中文摘要:你的报告与 #2900 是同一机制(损坏家族第 9 种:日志看似平衡但闭合回合内悬空 tool_calls)——两份独立报告相互印证。你的修复建议正确:复用 |
|
我支持在 turn/end 前关闭 pending 的工具调用。 不变量应为:只要存在已持久化但无匹配 tool/result 的 tool/call,就不应写入 turn/end。 建议方案: 跟踪当前 turn 的 pending 工具调用。 在写入 turn/end 前,调用现有 interruptedTurnClosers 逻辑,为每个 pending 调用合成 tool/result。 明确标记合成结果,例如 interrupted: true 或 synthetic: true。 js for (const pending of pendingToolCalls) {
await appendSyntheticToolResult({
toolCallId: pending.id,
reason: 'turn ended before tool result was produced',
synthetic: true,
});
}
await appendTurnEnd({ ... });这应能防止模型在下一轮看到未匹配的 tool/call 并返回 400 INVALID_REQUEST。 |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
When a turn ends with an error after a tool call was recorded (e.g. the scheduler crashes as in the duplicate-module issue above), no
tool/resultis written. The assistant message keeps itstool-callblocks, so every subsequent request is rejected by the model API withINVALID_REQUEST (insufficient tool messages following tool_calls message). The session becomes unusable.Why the existing repair doesn't cover this
interruptedTurnClosers()indsh-sessiononly synthesizes closing events for an open tail turn. In this failure mode the log already containsstep/endandturn/end(withreason.kind === "error"), which clearspendingCallsin the scan loop, so the repairer sees a "balanced" log and generates nothing.Log shape at the failure point:
Suggested fix
In the error path that ends a turn, close pending tool calls before writing
turn/end— e.g. reuse the same synthetictool/resultgeneration asinterruptedTurnClosers(ToolOutcomeUnknownError/ToolNotStartedError), or haveinterruptedTurnClosersalso close calls found in a turn whoseturn/endcarries an error reason.This would turn "any scheduler exception bricks the whole session" into "one failed turn, everything else keeps working".
中文版
概述
当一轮对话在已记录工具调用之后以错误结束(例如上面 #2660 中调度器崩溃的情况),不会写入任何
tool/result。assistant 消息保留其tool-call块,此后每次请求都会被模型 API 以INVALID_REQUEST (insufficient tool messages following tool_calls message)拒绝。会话从此不可用。为什么现有修复机制覆盖不到
dsh-session中的interruptedTurnClosers()只对开放尾轮合成补全事件。在这种失败模式下,日志里已经写入了step/end和turn/end(reason.kind === "error"),扫描循环会清空pendingCalls,于是修复器认为日志"已平衡",什么也不生成。失败点的日志形态:
建议修复
在结束轮次的错误路径中,写入
turn/end之前先闭合挂起的工具调用——例如复用interruptedTurnClosers的合成tool/result生成逻辑(ToolOutcomeUnknownError/ToolNotStartedError),或让interruptedTurnClosers同时闭合那些turn/end带错误原因的轮次中发现的未闭合调用。这样就能把"任何调度器异常都会毁掉整个会话"变成"一次失败的轮次,其余一切照常"。
All reactions