fix(openai): generate fallback id for missing streaming tool calls#78
Merged
Conversation
LIlGG
approved these changes
Jul 3, 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.
部分 OpenAI-compatible 供应商在流式工具调用返回中,可能会省略
tool_calls[].id。例如 DashScope / 阿里云百炼在某些模型的工具调用流中只返回工具名称和参数增量,不返回 tool call id。当前 AI Foundation 会将该空 id 继续转换为 Halo 的
tool-callstream part,最终触发校验失败:tool-call stream part toolCallId must not be blank导致 Agent 工具调用流程中断。
修改内容
tool_calls时,为缺失的 tool call id 生成兜底 idmessage.tool_calls缺失 id 时也增加兜底处理function处理修改前:

修改后:
