// Web search retry: non-reasoning gpt-4.1-mini + gpt-5.5 at low effort; read message content + annotations directly. import { client, attempt, save } from "./lib"; const out: any[] = []; for (const [model, extra] of [["gpt-4.1-mini", {}], ["gpt-5.5", { reasoning: { effort: "low" } }]] as [string, any][]) { out.push(await attempt(`web_search:${model}`, async () => { const stream = await client.responses.create({ model, tools: [{ type: "web_search", search_context_size: "low" }], ...extra, input: "Who won the most recent FIFA World Cup? Answer in one sentence with a citation.", max_output_tokens: 200, stream: true } as any); const order: string[] = []; let final: any = null; const annEvents: any[] = []; for await (const ev of stream as any) { if (!order.includes(ev.type)) order.push(ev.type); if (ev.type === "response.output_text.annotation.added") annEvents.push(ev); if (/^response\.(completed|incomplete|failed)$/.test(ev.type)) final = ev.response; } const msg = final.output.find((o: any) => o.type === "message"); return { event_order: order, status: final.status, incomplete: final.incomplete_details, output_types: final.output.map((o: any) => o.type), usage: final.usage, web_search_calls: final.output.filter((o: any) => o.type === "web_search_call").map((w: any) => ({ id: w.id, status: w.status, action: w.action })), message_content: msg?.content?.map((c: any) => ({ type: c.type, text: c.text?.slice(0, 300), annotations: c.annotations })) ?? null, annotation_events: annEvents.slice(0, 2) }; })); } save("09b-web-search-retry", out);