Prhub

#44608 [Bugfix][Responses API] Set id on function_call item in streaming done event

原始 PR 作者 ankrovv 合并时间 2026-06-11 11:52 文件变更 1 提交数 2 评论 1 代码增减 +1 / -1

执行摘要

修复函数调用流式事件 id 为空

修复 Harmony 流式函数调用完成事件中 id 为 null 的 bug,确保 output_item.done 事件包含正确的 id 字段。PR body 指出 item_id 被存储为额外字段,而真正的 id 保持 None。

值得快速合入,属于明确的字段映射 bugfix,改动小而精准。

讨论亮点

仅有 reviewer sfeng33 批准,无其他讨论。

实现拆解

  1. vllm/entrypoints/openai/responses/streaming_events.pyemit_function_call_done_events 函数中,将 ResponseFunctionToolCall 构造参数 item_id 替换为 id
  2. 该修改与已有 emit_simple_tool_call_done 模式一致,确保 response.output_item.done 事件中 id 字段不再为 null。
文件 模块 状态 重要度
vllm/entrypoints/openai/responses/streaming_events.py 请求路由 modified 4.81

关键符号

emit_function_call_done_events

关键源码片段

vllm/entrypoints/openai/responses/streaming_events.py core-logic

核心修复文件,修改了 ResponseFunctionToolCall 的构造参数,将 item_id 改为 id。

# vllm/entrypoints/openai/responses/streaming_events.py
# 函数调用完成时,发射 arguments done 事件和 output item done 事件
# 修复前 id 字段始终为 None,因为传入了错误的 item_id 参数
def emit_function_call_done_events(
    function_name: str,
    arguments: str,
    state: StreamingState,
) -> list[StreamingResponsesResponse]:
    events: list[StreamingResponsesResponse] = []
    events.append(
        ResponseFunctionCallArgumentsDoneEvent(
            type="response.function_call_arguments.done",
            arguments=arguments,
            name=function_name,
            item_id=state.current_item_id, # 此 event 使用 item_id,正确
            output_index=state.current_output_index,
            sequence_number=-1,
        )
    )
    function_call_item = ResponseFunctionToolCall(
        type="function_call",
        arguments=arguments,
        name=function_name,
        # 修复:将 item_id 改为 id,这样 output_item.done 中 id 字段不再为 null
        id=state.current_item_id,
        output_index=state.current_output_index,
        sequence_number=-1,
        call_id=state.current_call_id,
        status="completed",
    )
    events.append(
        ResponseOutputItemDoneEvent(
            type="response.output_item.done",
            sequence_number=-1,
            output_index=state.current_output_index,
            item=function_call_item,
        )
    )
    return events

评论区精华

没有提炼出高价值讨论线程

当前评论区没有形成足够清晰的争议点或结论,后续有更多讨论时会体现在这里。

风险与影响

风险极低:仅修改了一个构造参数的键名,从 item_id 改为 id,且同函数内 item_id 在其他位置(ResponseFunctionCallArgumentsDoneEvent)仍保留,不影响其他逻辑。

影响范围为 Responses API 流式函数调用事件消费者。修复后,客户端能够正确获取函数调用项的 id,提升兼容性和一致性。

关联 Issue

未识别关联 Issue

当前没有检测到明确关联的 Issue 链接,后续同步到相关引用后会出现在这里。

完整报告

参与讨论