fix(ai): handle statusless hosted search completions
This commit is contained in:
@@ -3064,7 +3064,7 @@ export async function processResponsesStream<TApi extends Api>(
|
||||
}
|
||||
closeOpenItem(event.output_index, item.id, entry, item.call_id, prefixedFunctionCallItemKey(item.call_id));
|
||||
stream.push({ type: "toolcall_end", contentIndex, toolCall, partial: output });
|
||||
} else if (item.type === "web_search_call" && item.status === "completed") {
|
||||
} else if (item.type === "web_search_call" && (item.status === undefined || item.status === "completed")) {
|
||||
// A completed provider-hosted web search is progress evidence even when
|
||||
// the model never surfaced an answer; the agent loop continues from it.
|
||||
sawCompletedWebSearchCall = true;
|
||||
|
||||
@@ -673,6 +673,28 @@ describe("processResponsesStream: terminal events", () => {
|
||||
expect(output.stopDetails).toEqual({ type: "pause_turn" });
|
||||
});
|
||||
|
||||
test("pauses a status-less hosted web search done item that has no visible assistant output", async () => {
|
||||
const output = makeOutput();
|
||||
const stream = { push: () => {}, end: () => {} } as never;
|
||||
|
||||
await processResponsesStream(
|
||||
makeStream([
|
||||
{
|
||||
type: "response.output_item.done",
|
||||
output_index: 1,
|
||||
item: { type: "web_search_call", id: "ws_1", action: { type: "search" } },
|
||||
},
|
||||
{ type: "response.completed", response: { id: "resp_search", status: "completed" } },
|
||||
]),
|
||||
output,
|
||||
stream,
|
||||
makeModel(),
|
||||
);
|
||||
|
||||
expect(output.stopReason).toBe("stop");
|
||||
expect(output.stopDetails).toEqual({ type: "pause_turn" });
|
||||
});
|
||||
|
||||
test("finishes a hosted web search when the response includes visible output", async () => {
|
||||
const output = makeOutput();
|
||||
const stream = { push: () => {}, end: () => {} } as never;
|
||||
|
||||
Reference in New Issue
Block a user