Replies: 3 comments 1 reply
|
I traced this against rc.8 (
For current operators, I would contain it in this order: cancel the active turn, stop follow-up prompts, reload or disable the exact MCP client row/Host, require a successful new initialization and complete tool discovery, then make one proof call from a fresh Agent Session. Retry automatically only for read-only or proven-idempotent work; verify unknown writes before replay. For the runtime, a useful repair contract is: classify session-invalid errors, atomically invalidate only that generation, collapse concurrent failures into one reconnect, stop new admission, rediscover tools, and open a circuit if the recovered generation returns the same fingerprint. Reasoning-delta aggregation may reduce event volume, but it is separate from MCP lifecycle correctness. I wrote the full source-backed runbook, including stdio/HTTP recovery branches, retry safety, and acceptance gates: |
|
Thanks @denial123789 for the trace and recovery analysis. I reproduced #3489 as an expired stateful Streamable HTTP session and published a scoped reference implementation as one commit against current master b150a55:
The patch retires only protocol-proven session loss: HTTP 404 while the exact SDK transport still owns the MCP session ID, plus the exact reported legacy McpError(-32001, "Unknown or expired MCP session") fingerprint. It withdraws stale tool definitions synchronously, fences concurrent and late generations, closes the old client, then reuses the existing bounded fresh-Initialize and complete-discovery path. The failed tool call is surfaced unchanged and is never replayed automatically. Stateless 404s, ordinary timeouts, authentication/server failures, result-level MCP errors, and stdio behavior remain unchanged. Verification on that exact commit:
This is intended as a cherry-pickable reference implementation; it does not claim upstream adoption. |
|
MCP 生命周期那一半,@denial123789 的溯源和 @Jstn-1g 的参考实现已经把话说尽了,我没有增量。我想说的是被这两份工作显式排除在外的那另一半——你提的"重复错误熔断"。 @denial123789 写了 "Reasoning-delta aggregation may reduce event volume, but it is separate from MCP lifecycle correctness",@Jstn-1g 的补丁也明确 scope 掉了重放与熔断。两位都是对的:那确实是独立的一件事。但它不是次要的一件事——你的数据里,67 次工具调用只有 6 次是那个错误,剩下 61 次是模型在错误反馈下的重新规划。生命周期缺陷造成 6 次失败,缺少刹车造成了另外那 500 多秒。 这个形状我这两天在社区里见到第四次了
共同点是同一句话:工具层返回了一个模型无法据以纠正行为的错误,而系统里没有任何东西注意到"同一个错误又来了"。 四例里的错误性质各不相同(参数格式、流式重组、会话过期),但失败模式完全一样,这说明缺的不是针对某一类错误的修复,而是一个通用的观察:确定性错误重复出现时,重试不会有不同结果。 为什么值得单独提熔断被反复归类为"优化项",我觉得这是低估了。它有一个别的修法都没有的性质:它不需要知道错误是什么意思。
换句话说:每修一个具体根因,只挡住一类循环;加一次熔断,挡住所有还没被发现的循环。 对一个正在快速迭代的运行时来说,后者的边际价值只会越来越高。 @denial123789 的修复契约里其实已经有它了——"open a circuit if the recovered generation returns the same fingerprint"。我想说的是这一句值得从 MCP 的上下文里抽出来放到工具执行层:不管这个工具是 MCP 的、原生的还是插件注册的,同一个 (工具, 错误指纹) 在一轮里重复 N 次就该停。 如果要提成独立条目,我建议把上面四帖一起引上——一个失败模式有四份独立复现,比任何单帖都更能说明它是结构性的。 我不推荐你换 MCP 运行时,理由要说清楚我维护 pi2dsh,它能跑一套 Pi 生态的 MCP 运行时,我们在真 DSH loop 上端到端验过 stdio / Streamable HTTP / SSE 和重连。按理说这里该推销一下。但我不推荐,因为 @denial123789 划的那条线正好是我没有证据的那条线:
我们验过的"重连"是传输层断开触发的那种。"应用层 没测过就不能说绕得开。你换过去很可能只是换成另一套同样不认 我们也不修 DSH 自家组件—— (另:你那份证据包的质量——两轮的调用数/错误数/事件数/reasoning delta 平均长度全都量化了——是我在这个社区见过最好的之一。上面那张四帖对照表能成立,正是因为你把"6 次错误 vs 67 次调用"这个比例摆了出来;换成"MCP 一直报错"就什么都推不出来了。) |
Uh oh!
There was an error while loading. Please reload this page.
DSH_MCP_Expired_Session_Bug_Evidence_20260820.zip
I reproduced an MCP session recovery problem in DeepSeek Harness.
After the MCP session expires, DSH continues exposing the stale tools. Every subsequent call returns:
MCP error -32001: Unknown or expired MCP sessionDSH did not appear to reinitialize the MCP connection, refresh
tools/list, remove the unavailable tools, or stop repeated calls with the same error.I reproduced it in two turns:
The model repeatedly replanned after the tool failures, but changing the model would not repair an expired MCP session. I believe the primary problem is DSH's MCP lifecycle handling, amplified by the lack of a repeated-error circuit breaker and very fine-grained reasoning events.
Expected behavior:
tools/listRelated discussions:
Could you confirm whether
-32001 Unknown or expired MCP sessionis currently treated as a recoverable error, and whether automatic MCP reinitialization or repeated-error circuit breaking is planned?I have attached a sanitized evidence package containing timestamps, metrics, reproduction steps, event counts, and reasoning-delta samples. It excludes credentials and private business data.
All reactions