fix(openai-responses): keep open function calls when starting text/thinking

- Stopped prematurely closing function call parts on output_text and thinking_start.
- Only close the open part when it is not a function_call.
This commit is contained in:
can1357
2026-06-08 03:15:27 +02:00
parent 622f0ddc8a
commit 04a931337f
@@ -966,8 +966,7 @@ export function encodeStream(
cur = state.open;
cur.currentPartText = "";
} else {
closeOpenFunctionCalls();
if (state.open) closeOpen();
if (state.open && state.open.kind !== "function_call") closeOpen();
cur = openMessage();
}
const part = { type: "output_text", text: "", annotations: [] as never[] };
@@ -1018,8 +1017,7 @@ export function encodeStream(
break;
}
case "thinking_start": {
closeOpenFunctionCalls();
if (state.open) closeOpen();
if (state.open && state.open.kind !== "function_call") closeOpen();
openReasoning(ev.partial, ev.contentIndex);
break;
}