From 423c070900549e0f248fa086d3798dca9238c32c Mon Sep 17 00:00:00 2001 From: Hoan Luu Huu <110280845+xquanluu@users.noreply.github.com> Date: Wed, 6 May 2026 22:47:04 +0700 Subject: [PATCH] fixed HTTP llm.toolHook does not support openAI (#1547) --- lib/tasks/llm/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/tasks/llm/index.js b/lib/tasks/llm/index.js index 68b8ca68..a0c93772 100644 --- a/lib/tasks/llm/index.js +++ b/lib/tasks/llm/index.js @@ -114,8 +114,14 @@ class TaskLlm extends Task { const tool_response = await this.cs?.requestor.request('llm:tool-call', this.toolHook, {tool_call_id, ...data}); // if the toolHook was a websocket it will return undefined, otherwise it should return an object if (typeof tool_response != 'undefined') { - tool_response.type = 'client_tool_result'; - tool_response.invocation_id = tool_call_id; + // If the webhook didn't declare a `type`, assume the legacy Ultravox-style + // envelope and fill it in. Otherwise pass the response through unchanged so + // vendors like OpenAI ('conversation.item.create') receive the exact shape + // their realtime API expects. + if (!tool_response.type) { + tool_response.type = 'client_tool_result'; + tool_response.invocation_id = tool_call_id; + } this.processToolOutput(tool_call_id, tool_response); } }