Repository navigation
Description
问题描述
OpenCode / OpenChamber 使用 claude-opus-5-5 多轮对话,前几轮能正常回答,随后请求失败。向同一对话发送“继续”后,仍因相同的 messages.2 system 消息位置错误而失败,两次均没有生成回答内容。
本报告包含客户端错误记录,以及用户提供的 vm2api 入站、出站请求体对照。出站额外插入了一条带正文的 # Environment system 消息,紧接着是另一条 system 控制轮:前者既不紧邻 assistant、也不位于数组末尾,是与上游位置约束冲突的直接线索。具体产生该消息的函数及实际运行版本尚未核实。
客户端及版本
- 客户端:OpenCode,界面为 OpenChamber;当前本地 CLI 为
v2.2.6。 - 模型:
claude-opus-5-5。请求体顶层output_config.effort=medium,历史 directive-only system 轮为xhigh;客户端消息记录的 variant 为xhigh。这些是不同层级的实际值,不应混为一谈。 - 出站 billing 文本标识为
cc_version=2.1.303.bdf; cc_entrypoint=cli;它是出站请求中的标识,不作为实际运行二进制版本的证明。 - vm2api 实际运行版本、部署方式、槽位类型和账号类型:本次未采集,不能确认是否为最新版本,也未做升级验证。
- 已取得用户提供的入站/出站请求体;具体请求入口、vm2api request ID 和 attempts 尚未取得。
实际发生的操作
- 在同一个对话中进行多轮普通文字问答,前几轮正常。
- 继续提出请求,客户端记录
provider.invalid-request,回答内容为空。 - 稍后向原对话发送“继续”,再次记录相同错误,回答内容仍为空。
频率:同一个对话中观察到两次失败;不是独立新会话的最小复现,暂不能声称必现。本次没有为了复现重新发送业务内容或调用生产推理接口。
入站 / 出站对照(正文全部替换)
以下是从提供的两份请求体提取的结构片段,不是完整可执行请求。所有自然语言正文、工具参数、工具结果、thinking 及其签名均已省略或替换;保留消息顺序、角色、content 形态及控制字段。索引均为 JSON 数组的 0-based 索引。
入站:顶层有调用方 system;消息角色顺序为 user, user, system, user, assistant, user。
{
"model": "claude-opus-5-5",
"system": [{"type": "text", "text": "[REDACTED_CALLER_SYSTEM]", "cache_control": {"type": "ephemeral", "ttl": "1h"}}],
"messages": [
{"role": "user", "content": [{"type": "text", "text": "[REDACTED_USER_1]"}]},
{"role": "user", "content": [{"type": "text", "text": "[REDACTED_CONTEXT_SUMMARY]"}]},
{"role": "system", "content": [], "output_config": {"effort": "xhigh"}},
{"role": "user", "content": [{"type": "text", "text": "[REDACTED_USER_2]"}]},
{"role": "assistant", "content": [
{"type": "thinking", "thinking": "[REDACTED]", "signature": "[REDACTED]"},
{"type": "tool_use", "id": "toolu_REDACTED", "name": "compress", "input": {}}
]},
{"role": "user", "content": [{"type": "tool_result", "tool_use_id": "toolu_REDACTED", "content": "[REDACTED_RESULT]", "cache_control": {"type": "ephemeral", "ttl": "1h"}}]}
],
"stream": true,
"max_tokens": 128000,
"thinking": {"type": "adaptive", "display": "summarized", "block_binding": {"prefix_mismatch_behavior": "drop_block"}},
"output_config": {"effort": "medium"}
}出站:调用方顶层 system 正文转入首条 user 的 <system-reminder>,原来相邻的两条 user 合并;随后额外插入带正文的 # Environment system。角色顺序变为 user, system, system, user, assistant, user。
{
"model": "claude-opus-5-5",
"system": [
{"type": "text", "text": "[REDACTED_BILLING_HEADER]"},
{"type": "text", "text": "[REDACTED_CLI_IDENTITY]"},
{"type": "text", "text": "[REDACTED_HARNESS]", "cache_control": {"type": "ephemeral", "ttl": "1h"}},
{"type": "text", "text": "__SYSTEM_PROMPT_DYNAMIC_BOUNDARY__"}
],
"messages": [
{"role": "user", "content": [
{"type": "text", "text": "<system-reminder>\n[REDACTED_CALLER_SYSTEM]\n</system-reminder>"},
{"type": "text", "text": "[REDACTED_USER_1]"},
{"type": "text", "text": "[REDACTED_CONTEXT_SUMMARY]"}
]},
{"role": "system", "content": "# Environment\n[REDACTED_ENVIRONMENT]"},
{"role": "system", "content": [], "output_config": {"effort": "xhigh"}},
{"role": "user", "content": [{"type": "text", "text": "[REDACTED_USER_2]"}]},
{"role": "assistant", "content": [
{"type": "thinking", "thinking": "[REDACTED]", "signature": "[REDACTED]"},
{"type": "tool_use", "id": "toolu_REDACTED", "name": "mcp__compress", "input": {}}
]},
{"role": "user", "content": [{"type": "tool_result", "tool_use_id": "toolu_REDACTED", "content": "[REDACTED_RESULT]", "cache_control": {"type": "ephemeral", "ttl": "1h"}}]}
],
"stream": true,
"max_tokens": 128000,
"thinking": {"type": "adaptive", "display": "summarized", "block_binding": {"prefix_mismatch_behavior": "drop_block"}},
"output_config": {"effort": "medium"},
"betas": [
"oauth-2025-04-20",
"interleaved-thinking-2025-05-14",
"context-management-2025-06-27",
"per-turn-control-2026-07-01",
"mid-conversation-tool-changes-2026-07-01",
"effort-2025-11-24",
"thinking-binding-controls-2026-08-01",
"extended-cache-ttl-2025-04-11",
"mid-conversation-output-config-2026-07-01"
]
}关键区别:
- 入站
messages[2]是content: [] + output_config的 directive-only 轮,报错原文明确说明这种形态允许出现在任意位置;不能仅因报错写着messages.2就认定它非法。 - 出站
messages[1]是新增的非空 Environment system,后面是 directive-only system,再后面是 user。它不符合报错所述的普通 system 位置要求。 - 报错的
messages.2与上述 0-based 索引不能直接等同;仍需维护者核实上游索引口径,以及提供的出站快照之后是否还有消息转换。这里不宣称已经确定报错精确对应哪一条消息。 tools定义和身份metadata没有附出;原始附件不上传。脱敏片段保留了历史tool_use/tool_result配对及工具名的出站变化,但没有重放原签名。
错误证据(已脱敏)
两次错误均发生于 2026-11-11,UTC+8,分别约为 10:09 和 10:26。前一次客户端记录的 error.status 为 400,后一次为 200,但二者的消息终态均为 finish: "error",且回答内容数组均为空。
共同的错误正文:
messages.2: role 'system' must precede an 'assistant' message or end the array; the directive-only form (content: [] with output_config) is accepted at any position
后一次客户端保存的响应体:
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "messages.2: role 'system' must precede an 'assistant' message or end the array; the directive-only form (content: [] with output_config) is accepted at any position",
"code": "upstream_invalid_request"
}
}这里的 200 仅指客户端错误对象保存的状态,不能当作推理成功,也不能据此确认真实上游 HTTP 状态或流式提交边界。
期望行为
同一对话应能正常继续。若问题来自消息重写,应在保留 system 指令语义的前提下,保证出站非空 system 消息符合上游要求的位置约束;不要通过静默丢弃系统指令来规避错误。
希望协助定位
- 检查新增 Environment system 的插入位置,尤其是首条 user 合并后、历史 directive-only system 之前这一组合;保留控制轮语义的同时保证普通 system 位置合法。
- 核实错误索引与最终上游 wire body 的对应关系,确认是否存在快照之后的转换。
- 修复后请覆盖“相邻 user + 中间 directive-only system + 后续 user + 工具往返”场景,以及普通 system 与 directive-only system 相邻的情况,并说明修复版本。当前仅确认请求体差异与错误线索,未核实具体源码根因。
相关问题与验证边界
已按错误关键词检索 Issues,未找到相同错误原文的报告。#285、#324、#375 均涉及 system 消息兼容性,但描述的分别是模型支持范围、缓存行为和空 system 内容错误,与本次位置约束错误不同;这里只作相关线索,不认为已确认同因。
本次未修改服务配置、重启服务或实施修复。未公开原始对话、业务需求、内部项目/策略名称、会话标识、本机路径、域名/IP、邮箱、密钥、Cookie、认证头或完整配置文件。
Activity
dofastted commentedon Nov 17, 2026
已由 #1162(1881d65f01)修复:Environment 注入移到 assistant 边界,相邻已有正文 system 时合并,不再产生相邻的两条非空 system。随 v1.4.126 发布,升级后如仍复现请重开。