Repository navigation
feat: show web searches and the pages they found in chats - #29861
Conversation
99e4658 to
0922e9a
Compare
This comment was marked as outdated.
This comment was marked as outdated.
|
Chat: Review posted | View chat Review history
deep-review v0.13.0 | Round 1 | Last posted: Round 1, 27 findings (1 P1, 14 P3, 5 P4, 7 Nit), REQUEST_CHANGES. Review Finding inventoryFinding inventory: PR #29861Findings
Contested and acknowledgedLaw analysisNot run. Effective additions 844, below the 1000 threshold. Round logRound 1Netero first pass: 3 P3, 1 Nit, 1 Note, no P0, so the panel ran. Full panel (round 1): ging-go, ging-ts, ging-react, nami, melody, kurapika, ryosuke, luffy (triggered specialists), pariston, mafuuu (core), bisky (tests changed), gon, leorio (once-per-PR floor), zoro (random wildcard from the distilled set). 14 reviewers, over the 12 target because 8 specialists triggered: ging-go, ging-ts, ging-react (Go, TS, TSX files), nami (frontend), melody (Go result JSON and Fantasy call input consumed by TS), kurapika (provider URLs rendered as links), ryosuke (chatprompt imports chatopenai), luffy (new UI feature). Cross-check: CRF-6 raised to P1 (Ryosuke P2, Luffy and Pariston P1; higher wins). Orchestrator verified Downgrades. Gon rated eight comment findings P2. Keep argument: AGENTS.md requires substantive comments, and duplicated rationale drifts. Downgrade reason: the code works and the consequence is maintenance cost under a project convention, which the severity scale defines as Nit. CRF-25, CRF-26, CRF-27 posted as Nit; CRF-32 to CRF-36 dropped with reasons in the Status column. CRF-26: Gon and Zoro disagreed on which copy to keep; the comment keeps the rationale at About deep-reviewCRF = Coder Review Finding (P0-P4, Nit, Note)
|
This comment was marked as outdated.
This comment was marked as outdated.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
667c824 to
ffea652
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
a41a15e to
5c3ea99
Compare
db6c652 to
c221f14
Compare
This comment was marked as outdated.
This comment was marked as outdated.
c542b97 to
5136929
Compare
5136929 to
6493edf
Compare
Docs previewCheck off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here. |
Moves the fantasy pin to the tip of `coder_2_33` (`85ffbbe`). That commit is coder/fantasy#72, which merges 87 upstream charmbracelet/fantasy commits, v0.40.0 to v0.45.5. Between the two pins 117 files change. Upstream's own v0.40.0 to v0.45.5 change, without tests, testdata, examples, `go.sum` and the kronk provider, is 43 files, +2271/−928. ## What reaches chatd chatd builds only the `anthropic`, `openai` and `openaicompat` fantasy clients (`chatprovider.ModelFromConfig`); other vendors reach it through the AI Gateway on one of those. So the upstream changes to the Google, Vercel, OpenRouter, Bedrock, Azure and kronk providers, and to the `fantasy.Agent` loop and its retries, do not run in chatd. These do: - **Chat Completions and openaicompat streams** keep reasoning on batched and DeepSeek-shaped chunks, keep `finish_reason: length` when tool calls are truncated, and stop sending empty reasoning fields. openaicompat drops assistant turns that hold only reasoning. - **Token usage.** When an OpenAI-shaped backend reports reasoning tokens apart from completion tokens (reasoning larger than output), output tokens now include them, so that backend's reported output tokens and cost rise. OpenAI's own shape, where reasoning is a subset, is unchanged. - **Responses.** A content-filtered turn no longer reads as a tool-call turn. - **Context overflow.** Baseten, Fireworks and Parasail prompt-length errors set `ContextTooLargeErr`, which compaction acts on. - **Anthropic.** Tool calls whose content block never closes are reported. For Claude 5 models, thinking defaults to `display: "summarized"` when the chat config sets none; a configured display still wins. `TestThinkingDropBlockModel_RetriesWithEffort` now expects the field in the retry body. - **Anthropic keepalives.** Fantasy forwards `message_start`, `message_delta` and unknown events as content-free `keepalive` parts. The first one arrives before any model output, so this PR makes `ttft_seconds` and the `time_to_first_token` stage skip them, as they skip warnings. They still reset the stream silence guard. `processStepStream` ignores them, and the debug recorder counts them in its part count but records no content. - **Tool-result media** now goes through upstream's shared `ToolRunBuffer`, which replaces coder/fantasy#64 and does the same thing. #72 keeps coder's anthropic-sdk-go and openai-go forks, Go 1.26 and kronk v1.31.5, so upstream's SDK and Go moves do not come along. `go mod tidy` raises the modules fantasy v0.45.5 requires, among them otel exporters v1.47, the AWS SDK, `google.golang.org/api` v0.307 and go-openapi v1. All are upgrades. The `go.mod` comment now names #72 as the upstream sync. #29861 stacks on this PR to pin coder/fantasy#62. <details> <summary>Verification</summary> - `go build ./...`. - `go test` passes on every package that imports fantasy (`coderd/x/chatd/...`), and `go test ./coderd -run 'TestChat|TestExpChat|TestMCP|TestAIBridge'` passes. - `TestGuardedStreamTTFTStage/WarningsAndKeepalivesThenContentObservesOnce` fails without the TTFT change (TTFT observed 0s instead of 1s) and passes with it. - `make pre-commit` passes. The generated Prometheus docs pick up the metric help change. Not verified against live backends in this PR: the stream fixes, the token usage change and the context-overflow patterns have no coder test against a real provider. coder/fantasy#72 reports a local chatd run against the AI Gateway on Anthropic, Responses, OpenAI Chat and openaicompat. </details> > 🤖 This PR was created with the help of Coder Agents, and _will be_ reviewed by a human. 🏂🏻
6493edf to
e27b7b6
Compare
Provider-executed web_search calls were hidden in the Agents UI, and
chatd persisted their result as {} because the queries and sources only
lived in provider metadata that API responses strip.
The Fantasy pin now requests web_search_call.action.sources, reads
action.queries with the deprecated action.query as fallback, and puts
the queries in the call input. chatd persists the consulted source URLs
as the result, so both survive a reload. The UI renders web_search as
its own row with the queries and http(s) source links, separate from
url_citation pills. Other provider-executed tools stay hidden.
An OpenAI call arrives once its search finished, but the sources only
come with the completed response, so that row does not show a spinner
while the answer streams.
Fix the stale test comment that said the result carries the queries, drop comments that repeat field names, and say that Fantasy, not the provider API, keeps consulted URLs only in metadata. The pin moves to the fantasy pin branch with the matching comment cleanup from coder/fantasy#62. It has no behavior change.
Each provider-executed web search row now lists the pages that search
found, taken from source parts tagged with the search's tool call ID.
Untagged source parts are the answer's citations and stay in the source
row. A row finishes when its result arrives, for both providers, so the
check on the queries key in the call input is gone.
chatd stores the tag on source parts and marks a search failed from the
Anthropic error code or the OpenAI item status. The search result goes
back to {} and the OpenAI-specific result JSON is removed.
The UI labels open_page and find_in_page actions, shows searches that
never finished, and only links http and https URLs in both rows.
parseStringList in the tools utils owns the string form, which only typed fixtures use; the API sends queries as an array.
chatd stores a citation when it arrives, before the text that was streaming, so reloaded answers showed the source row above the text. Live, the row split the text in two. Both parsers now move a citation row after the text that follows it. Also URL-encode the hostname in the favicon request.
Moving the citation row after the answer text made cited answers end in a sources block, so they lost the copy button and got the bottom spacer instead.
The helper unit tests and label stories repeated what rendering a Tool row checks, and the Anthropic timeline story repeated a parsing test. The deprecated-query and no-query chat cases, and the loop's OpenAI failure case, repeated Fantasy's tests and the chat's failed case.
Working blocks counted each provider-executed result as a hidden step, which was right while web searches rendered no row. Web searches now render as tool rows, so they were counted twice, and their citation rows were counted on top. Only provider calls without a row count as hidden steps now, and citations count only when a block has no provider search.
Citations were moved after their text once it arrived. A whitespace-only delta after a citation had no text block to extend, so the paragraph break was dropped. Answer text now goes before a trailing citation row as it arrives, which keeps both the break and the citation placement.
FE1 keeps rendered appearance in Pixel-captured stories and out of Vitest presence assertions. The label table and text checks go back to stories; Vitest keeps the renderer choice and which pages become links.
Replace the push loop and nested try with a shared parseJSON helper, map and every. parseArgs uses the same helper.
The static-components lint rule on main rejects calling a helper to choose the renderer during render. WebSearchRenderer now falls back to the generic renderer itself when a web_search call is not provider-executed.
The pin moves from the PR branch to its squash commit on coder_2_33, which adds only comment changes.
e27b7b6 to
6714bd4
Compare
Closes CODAGT-795
Problem
Provider-executed
web_searchcalls were invisible in Agents chats. The frontend skipped everyprovider_executedpart, and chatd stored each search result as{}. The only trace was one "Searched N results" row ofsourceparts per message. That row held citations for OpenAI and search results for Anthropic, with nothing to tell the two apart.Fix
Fantasy (feat: tag web search sources with the search that found them fantasy#62): a
sourcepart carries the ID of the search that found it (tool_call_id); citations carry none. OpenAI now:queries, orurlandpatternforopen_pageandfind_in_page.chatd: stores
tool_call_idonsourceparts. It marks a search failed when Anthropic returns anerror_codeor OpenAI afailedstatus. Otherwise the search's result stays{}.UI: each search is one row:
Untagged sources stay in the answer's source row, now labeled "N sources". Both rows link only
http:andhttps:URLs. Other provider-executed tools stay hidden, and a user-defined tool namedweb_searchkeeps the generic renderer.With the tag, each URL appears in exactly one row, so the search row no longer duplicates the citation pills, which was the concern CODAGT-795 raised. In one live gpt-4.1-mini answer, the search found 12 pages and the answer cited 1 of them.
Anthropic answers show no citations yet, because Fantasy drops Anthropic's text citations (CODAGT-1186).
AI Gateway needed no change:
aibridge/intercept/responsesforwards the request body, includinginclude, and relays upstream response bytes.TestChatOpenAIResponsesWebSearchruns through the AI Gateway daemon.The Fantasy pin is coder/fantasy#62's commit on
coder_2_33(90a0be3). Upstream: charmbracelet/fantasy#435.#30529 landed while this PR was open. It folds web searches into working blocks, written for searches that rendered no row. This PR keeps that handling for provider calls that render no row, and counts a shown web search once, as a tool, with its citations not counted again.
open_page, onefind_in_page, two citationsDecision log and verification
Why found pages come from the search item, not the end of the response. In 16 live OpenAI streams, gpt-4.1-mini and gpt-5-mini search items carried their found pages when they closed. The final
response.completedsummary added pages the answer cited to each search's list: all 7 URLs that appeared only there were cited. gpt-4.1 search items carried no pages, so gpt-4.1 searches show none. Taking the summary would have shown citations as found pages.Why a row finishes on its result. Both providers now send a search's result when the search ends. The UI no longer infers "finished" from the shape of the call input.
Bedrock Mantle. vercel/ai#18507 reported in August that Mantle rejected the sources include. Through Coder's AI Gateway today, Mantle (
openai.gpt-5.6-terra, us-east-1 and us-west-2) accepts it with HTTP 200, and a request with an invalid include listsweb_search_call.action.sourcesamong the supported values. So chatd does not special-case Bedrock. Whether Mantle returns found pages is unverified, because web search failed on the test account.Replay. Source parts are never sent to the model. The search result is
{}as before, or{"error": …}for a failed search.Existing chats. Anthropic found pages stored before this change have no tag, so they stay in the source row. Older OpenAI search rows show "Searched the web".
Not done.
provider_metadatathat the history API strips. This predates this PR (CODAGT-1187).prompt_cache_key(CODAGT-1188).web_search_callonly as an item reference, only withstore:true, and only right after reasoning from a stored response. Searches with no reasoning before them are tracked in chatd: OpenAI web searches without a preceding reasoning item are never replayed #30528.Verified on a local dev instance whose providers point at the dogfood deployment's AI Gateway:
open_page, onefind_in_page) and Claude Sonnet 4.5 (two searches).5c3ea995ae).Tests:
TestChatOpenAIResponsesWebSearch(a search with found pages and a cited page that appears only in the final summary, and a failed search) runs through the chat API and AI Gateway.TestProcessStepStreamProviderWebSearchcovers Anthropic results and errors. Frontend tests cover message parsing, streaming, which web search rows render as the web search tool, and which found pages become links. Stories capture each web search label and state. Query and action parsing is tested in coder/fantasy#62.