This commit is contained in:
Timothy Jaeryang Baek 2026-09-07 13:13:25 -04:00
parent f5fcf4c89f
commit e1bfefdf9f

View file

@ -499,7 +499,7 @@ function findOutputItemIndex(output: OutputItem[], item: OutputItem): number {
return output.findIndex(
(existing) =>
(!!item.id && existing?.id === item.id) ||
(!!item.call_id && existing?.call_id === item.call_id)
(!!item.call_id && existing?.type === item.type && existing?.call_id === item.call_id)
);
}
@ -522,7 +522,19 @@ export function applyResponseStreamEvent(
}
if (eventType === 'response.completed') {
return event.response?.output ? [...event.response.output] : output;
if (!event.response?.output?.length) return output;
// Completion covers one provider response, not the earlier tool-call rounds.
const nextOutput = [...output];
for (const item of event.response.output) {
const index = findOutputItemIndex(nextOutput, item);
if (index >= 0) {
nextOutput[index] = item;
} else {
nextOutput.push(item);
}
}
return nextOutput;
}
const nextOutput = [...output];