Repository navigation
[Bug] tool_addition blocks can only be in system messages — 会话中途技能/工具目录变化后,该会话在 Anthropic 官方端永久 400 INVALID_REQUEST #10563
Replies: 1 comment
|
Thanks for the request ids and the "still failing on the third turn" evidence — that is what made this diagnosable. I re-derived the mechanism from the shipped 0.2.1-rc.2 packages rather than from the report alone, and one part of the diagnosis needs correcting. The harness has no step that downgrades these blocks to a user/assistant message. Both serializers that can emit them refuse instead of relocating them: What the harness does do is decide whether to send these blocks at all from the model entry, not from the endpoint it points at. Two consequences follow, and they are both worth knowing before burning more turns on retries. Retrying cannot recover the session — only the outgoing request can be changed. And a fix aimed at "restore the system role" would not help: whether the official endpoint accepts the block turns on the Containment, available now. I packaged the projection as a plugin for the routes an operator names:
Mounting it is one patch entry; The evidence is wire-level, not object-level: driving the published What this does not fix, plainly: the plugin contains the symptom only on routes an operator names. The defect is that a capability describing an endpoint is declared on a model entry, and the real fix belongs in the core — either resolving the capability from the endpoint, or letting a route lose the declaration once its endpoint rejects the blocks. Until then this is a workaround, and I would rather say so than imply the report is closed. Two things from you would settle the remaining ambiguity: did the failing request carry that beta header, and does a turn with no tool-catalogue change succeed on the official endpoint? I could not test against the official API myself. |
Uh oh!
There was an error while loading. Please reload this page.
环境
nightly@anthropic-ai/sdk(含BetaToolRunner,支持tool_addition/tool_removal)现象
切换模型后该轮直接失败,UI 显示:
同一个会话切回自建 Anthropic 兼容端点则正常,说明这个块确实被发出去了,只是官方端校验更严。
复现条件
tool_addition内容块。代码定位
resources/app.asar第 181310–181312 行(另有 182083–182085、212480 两处相同实现):SDK 生成的这条消息 role 是
system,位置本来是对的。但官方 API 报的是messages.340里该块不在 system 消息中——说明在 SDK 之后、发请求之前,有一层把role:'system'的消息转成了普通消息(Anthropic 的messages数组不接受 system 角色,system 是顶层参数)。怀疑问题出在这个 provider 适配层的转换。期望行为
tool_addition/tool_removal块应当:system参数(或官方 API 允许的位置),或已确认:不是一次性,会持续失败
同一个会话连续三轮全部失败,错误码
INVALID_REQUEST,messages.340位置不变,request_id 各不相同:说明这条含
tool_addition的消息已经留在会话历史里,之后每次请求都会重发,重试无法恢复。该会话在切到官方端点前是正常的,切回自建 Anthropic 兼容端点也正常。影响:一旦某个长会话触发过工具/技能目录变更,它在 Anthropic 官方端点上就永久不可用(只能开新会话,或换宽松的上游)。这不是偶发失败,是会话级不可恢复。
同类报告(同族问题,但不是同一条)
先更正:早先用
search/issues查repo:deepseek-ai/deepseek-harness tool_addition得total_count=0,这个查询不覆盖 Discussions,所以当时"没人报过"的结论不成立。2026-10-22 改用 Discussions 列表 API 逐页扫标题+正文:最新 3,400 条(共 104 页 ≈10,300 条,未登录 API 限额 60 次/小时,其余 6,900 条未扫)中
tool_addition/can only be in "system" messages命中 0 条 → 这条错误文案应是首次报告。但"历史里某个块不合法 → 官方端每条后续请求永久 400、会话作废"这一族已被反复撞到,可作交叉引用:
INVALID_REQUEST.slice()切断 emoji 代理对 → 所有请求被 400 拒绝,且错误文案无法定位根因tool_callsmake every later request fail with 400 "insufficient tool messages"reasoning_content未回传 → 400INVALID_REQUEST共同点:provider 适配层往上游回传历史块时形状不合法,且因为块已固化在会话历史里,失败是会话级不可恢复的。本条的
tool_addition是这一族里的新的一块(触发点是会话中途工具/技能目录变化)。All reactions