// (h) Built-in web_search tool: output items, annotations (url_citation), streaming event names. import { client, attempt, save } from "./lib"; const out: any[] = []; for (const model of ["gpt-5.5", "gpt-5.4-mini"]) { out.push(await attempt(`web_search:${model}`, async () => { const stream = await client.responses.create({ model, tools: [{ type: "web_search" }], include: ["web_search_call.action.sources"], input: "In one sentence: what is the current top headline on reuters.com? Cite the source.", max_output_tokens: 200, stream: true } as any); const order: string[] = []; let final: any = null; for await (const ev of stream as any) { if (!order.includes(ev.type)) order.push(ev.type); if (ev.type === "response.completed" || ev.type === "response.incomplete") final = ev.response; } const msg = final.output.find((o: any) => o.type === "message"); const ws = final.output.find((o: any) => o.type === "web_search_call"); return { event_order: order, status: final.status, output_types: final.output.map((o: any) => o.type), usage: final.usage, web_search_call: ws ? { id: ws.id, status: ws.status, action: ws.action } : null, annotations: msg?.content?.[0]?.annotations ?? null, text: (final.output_text ?? "").slice(0, 300), tools_echo: final.tools }; })); } save("09-web-search", out);