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:
Chris
2026-03-27 12:25:16 -06:00
committed by GitHub
parent 508a6d99f5
commit 86d377a2f0

View File

@@ -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 },
},
],