mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-05 06:42:12 +03:00
fix: remove id/type from tool_calls delta chunks in Responses API streaming (#683)
In OpenAI Chat Completions streaming format, the tool call id and type should only appear on the first chunk (tool declaration). Subsequent argument delta chunks should only include index and function.arguments. Including id on every delta chunk caused openai-to-claude.ts to emit a new content_block_start for each chunk, breaking Claude Code ACP sessions with malformed Claude-format streams. Fixes #682 Co-authored-by: Chris Staley <christopher.staley@protonmail.com>
This commit is contained in:
@@ -464,6 +464,9 @@ export function openaiResponsesToOpenAIResponse(chunk, state) {
|
||||
}
|
||||
|
||||
// Function call arguments delta
|
||||
// NOTE: Do NOT include `id` or `type` here - only first chunk (response.output_item.added)
|
||||
// should have them. Including `id` on every chunk causes openai-to-claude.ts to emit
|
||||
// a new content_block_start for each delta, breaking Claude Code ACP sessions.
|
||||
if (eventType === "response.function_call_arguments.delta") {
|
||||
const argsDelta = data.delta || "";
|
||||
if (!argsDelta) return null;
|
||||
@@ -480,8 +483,6 @@ export function openaiResponsesToOpenAIResponse(chunk, state) {
|
||||
tool_calls: [
|
||||
{
|
||||
index: state.toolCallIndex,
|
||||
id: state.currentToolCallId,
|
||||
type: "function",
|
||||
function: { arguments: argsDelta },
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user