fix(agent): prevent premature stops in streaming tool loops - #150
Merged
Conversation
This was referenced Aug 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
Agent 客户端通过
/v1/messages、/v1/chat/completions或 CLI 端点运行长任务时,上游截断、异常 EOF、SSE 跨 TCP 分块或残缺工具调用会被桥接层包装成正常的stop/end_turn,导致客户端把未完成任务误判为完成。主要修改
length/max_tokensdelta.tool_calls,校验工具名及参数完整性tool_choice=required重试提示写入真实当前消息signature_delta,非流式 thinking block 补齐 signaturephase的正文回退为 answer,避免 Thinking/Max 模型只显示思考而丢失最终答案验证
运行:
node --test tests/*.test.js结果:23 项测试全部通过。新增测试覆盖:
当前测试环境没有真实 Qwen 账户,因此未执行真实账号的上游端到端请求;控制器级流式测试已覆盖原故障路径。