mirror of
https://github.com/justlovemaki/AIClient-2-API.git
synced 2026-04-25 09:25:59 +03:00
[GH-ISSUE #309] 防止 Claude 协议流式响应中重复发送 message_stop 事件 #220
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/AIClient-2-API-justlovemaki#220
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @oktj on GitHub (Feb 6, 2026).
Original GitHub issue: https://github.com/justlovemaki/AIClient-2-API/issues/309
问题描述
在 Claude 协议的流式响应中,
message_stop事件可能会被重复发送,导致客户端接收到冗余的结束信号。问题场景
message_stop事件finally块中会再次补充发送message_stop事件修复内容
文件变更
src/utils/common.jshandleStreamRequest函数(第 276-607 行)具体修改
新增状态跟踪变量(第 325 行)
检测流中的 message_stop 事件(第 386-389 行)
条件性发送结束标记(第 587-591 行)
技术细节
修复逻辑
hasMessageStop标志为falsetype属性type === 'message_stop',将标志设置为truefinally块中发送结束标记前,检查标志状态false时才补充发送message_stop事件影响范围
MODEL_PROTOCOL_PREFIX.CLAUDE)测试建议
测试场景 1: 上游已发送 message_stop
测试场景 2: 上游未发送 message_stop
测试场景 3: 其他协议不受影响
提交信息
相关代码位置
handleStreamRequest(src/utils/common.js:276-607)MODEL_PROTOCOL_PREFIX.CLAUDE(src/utils/common.js:57)备注
此修复确保了 Claude 协议流式响应的规范性,避免了重复事件可能导致的客户端解析问题或状态混乱。
@feimi8 commented on GitHub (Feb 6, 2026):
这个修改提交了吗
@liangbaikaia commented on GitHub (Feb 7, 2026):
+1
@justlovemaki commented on GitHub (Feb 8, 2026):
已更新