feat(core): 阻止长度截断的不完整工具调用执行并引导模型分块恢复 - #2649
Open
CyberXavier wants to merge 3 commits into
Open
Conversation
- 在 MessageMetadataKeys 中新增 MODEL_FINISH_REASON 常量用于存储模型完成原因 - 扩展 ModelCallEndEvent 类以包含 finishReason 字段 - 在 OpenAI 扩展中添加测试用例验证流式和非流式响应的完成原因保留 - 修改 ReActAgent 中的事件发射逻辑以传递上下文中的完成原因 - 在 ReasoningContext 中添加 finishReason 字段并处理分块响应中的完成原因 - 实现长度限制工具调用标记功能,在模型达到输出长度限制时标记不完整工具调用 - 在 ToolCallsAccumulator 中检测原始内容完整性并在元数据中标记不完整内容 - 更新 ToolExecutor 阻止具有长度限制不完整参数的工具调用执行 - 添加新的元数据键用于标识原始内容不完整和输出长度限制状态 - 新增 ReActAgentLengthLimitedToolCallTest 测试类验证完整的长度截断工具调用流程
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Contributor
Author
|
@jujn 您好,这个pr需要您帮忙审批一下 |
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.
fix:#2648
本 PR 修复 OpenAI 兼容模型因输出长度限制截断工具参数后,工具调用失败、遗留 pending 状态或重复重试同一大调用的问题。
主要改动:
finish_reason,覆盖流式与非流式响应。ModelCallEndEvent。{}的原有兼容行为。finish_reason=length且工具参数不完整时阻止实际工具执行。toolCallId和工具名的错误 ToolResult,避免遗留 pending tool call。length终止原因及缺失终止原因的响应保持原有执行与降级行为。测试覆盖:
finish_reason=length解析;修复后运行效果:
