QuantumNous / QuantumNous/new-api
Bug: /v1/messages streaming for qwen3.6-plus lacks content_block_stop/message_delta/message_stop, causing Claude Code to hang
Open
Nobody has claimed this yet.
bug
needs reproduction / insufficient info
- Dominant language
- Go
- Stars
- 48.5k
- Forks
- 11.6k
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 58
Description
⚠️ 提交前确认
- 我已确认当前使用的是最新版本的 New API
当前版本
v1.0.0-rc.4 - 我已搜索过现有 issues,未找到完全相同的问题
- 我已提供最小复现请求
- 我已隐藏所有敏感信息,例如 API Key、数据库密码、Token
版本信息
New API 部署方式:Docker
镜像:
calciumion/new-api:latest
复现步骤
执行以下请求:
curl -N http://YOUR_NEW_API_HOST:8979/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: sk-REDACTED" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "qwen3.6-plus",
"max_tokens": 4096,
"stream": true,
"extra_body": {
"enable_thinking": false
},
"messages": [
{
"role": "user",
"content": "你好,请只回复一句话。"
}
]
}'
实际行为
实际返回的 SSE 流大致如下:
event: message_start
data: {"type":"message_start", ...}
event: content_block_start
data: {"type":"content_block_start","index":0,"content_block":{"type":"thinking","thinking":""}}
event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"thinking_delta","thinking":"..."}}
...
event: content_block_stop
data: {"type":"content_block_stop","index":0}
event: content_block_start
data: {"type":"content_block_start","index":1,"content_block":{"type":"text","text":""}}
event: content_block_delta
data: {"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":"你好,"}}
event: content_block_delta
data: {"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":"我已按你的要求"}}
event: content_block_delta
data: {"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":"只回复"}}
event: content_block_delta
data: {"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":"这一句话。"}}
# 然后直接 EOF,没有后续事件
缺少以下事件:
event: content_block_stop
data: {"type":"content_block_stop","index":1}
event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn"}, ...}
event: message_stop
data: {"type":"message_stop"}
完整日志中可以看到 qwen3.6-plus 已经输出了 text block 和 text_delta,但是没有正常输出 content_block_stop、message_delta、message_stop。
期望行为
当上游模型流式输出结束时,New API 的 Anthropic /v1/messages 兼容层应该补齐完整的 Anthropic SSE 结束事件。
期望流式响应类似:
event: message_start
event: content_block_start
event: content_block_delta
event: content_block_stop
event: content_block_start
event: content_block_delta
event: content_block_stop
event: message_delta
event: message_stop
即至少在最后包含:
event: content_block_stop
data: {"type":"content_block_stop","index":1}
event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn"}}
event: message_stop
data: {"type":"message_stop"}
对比测试
同样请求更换模型为 mimo-v2.5-pro,流式响应可以正常结束:
event: content_block_stop
data: {"type":"content_block_stop","index":1}
event: message_delta
data: {"type":"message_delta","usage":{...},"delta":{"stop_reason":"end_turn"}}
event: message_stop
data: {"type":"message_stop"}
因此问题看起来不是 Claude Code 或 curl 客户端问题,而是 qwen3.6-plus 通过 New API /v1/messages streaming 转换时,SSE 结束事件未被正确输出。
额外测试
尝试在请求体中添加:
{
"enable_thinking": false
}
以及:
{
"extra_body": {
"enable_thinking": false
}
}
但返回中仍然包含大量:
{
"type": "thinking_delta"
}
说明 /v1/messages 路径下该参数可能没有被正确透传,或者当前渠道不支持该参数位置。
不过即使 thinking 没关闭,理论上只要最终 text block 后补齐 content_block_stop、message_delta 和 message_stop,Claude Code 也可以继续处理。
New API 最新版下,qwen3.6-plus 通过 /v1/messages stream=true 已能输出 text_delta,但缺少最终的 content_block_stop、message_delta、message_stop,导致 Claude Code 等不到结束信号而卡住
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the /v1/messages Anthropic streaming conversion entry point and reproduce the qwen3.6-plus request with the provided curl command. Trace the stream through the final text_delta and compare its termination with the mimo-v2.5-pro response. Done means the qwen3.6-plus stream emits content_block_stop, message_delta, and message_stop before EOF, with Claude Code no longer hanging.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 54/100