Surface Anthropic web search results as citations
extractCitations looks for web search results under search_results but the API sends them under content as a list of web_search_result blocks
so that branch never matches and search results never show up as citations
repro on claude-sonnet-5-5 with WebSearch
an agent with structured output searched and answered but got 0 citations
a plain prompt only got the 1 url the model cited inline
stream() builds its citations from events and never emitted search results either
this reads content and skips the error object a failed search returns
streaming now emits a Citation event for each result right where the web fetch one is emitted
a url that was already emitted in the step isn't emitted again so stream() ends up with the same list prompt() gets from unique('url')
that also means a url the model cites inline more than once only shows up once while streaming
after the change the same three runs each return the same 10 search result urls
https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool