Repository navigation
improve(agents): normalized web_search output contract with boundary-owned wrapping - #110308
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 17, 2026, 10:14 PM ET / July 18, 2026, 02:14 UTC. Summary PR surface: Source +273, Tests +762, Docs +78. Total +1113 across 9 files. Reproducibility: yes. from source and documentation: select Parallel, perform a search, then attempt the documented follow-up using the prior result’s Review metrics: none identified. Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review findings
Review detailsBest possible solution: Choose and document one compatible public Do we have a high-confidence way to reproduce the issue? Yes from source and documentation: select Parallel, perform a search, then attempt the documented follow-up using the prior result’s Is this the best way to solve the issue? No. A closed normalization boundary is plausible, but removing documented provider continuation/metadata fields without a stable replacement or migration is not the safest maintainable solution. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d8f2645c2ced. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +273, Tests +762, Docs +78. Total +1113 across 9 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (1 earlier review cycle)
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d0d1a93f53
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| query, | ||
| count: readFiniteNumber(result.count) ?? results.length, | ||
| ...(tookMs !== undefined ? { tookMs } : {}), | ||
| results, |
There was a problem hiding this comment.
Preserve provider metadata or update provider docs
When a selected provider returns a conforming results array, this normalized branch now emits only the generic fields; existing provider docs still promise web_search pass-through fields such as Parallel sessionId/searchId/warnings/usage and Exa highlightScores/summary (docs/tools/parallel-search.md:123-150, docs/tools/exa-search.md:128-132). For Parallel this also breaks the documented follow-up flow because callers can no longer read the prior sessionId; either include those fields in the declared contract or remove/replace the stale provider-specific docs/workflows.
Useful? React with 👍 / 👎.
… payloads through as raw
…ver metadata fields
…cumented contract
db03106 to
1421ccc
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1421ccc04a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| : typeof row.description === "string" | ||
| ? row.description | ||
| : Array.isArray(row.snippets) | ||
| ? row.snippets.find((value): value is string => typeof value === "string") |
There was a problem hiding this comment.
Preserve all Brave LLM-context snippets
When Brave is configured for llm-context, the provider emits every pre-extracted grounding chunk in snippets (see extensions/brave/src/brave-web-search-provider.runtime.ts:504-507), but this normalization keeps only the first string. Any result with multiple chunks therefore loses most of the page content before it reaches the model through generic web_search; join and wrap the snippets, or otherwise carry the full set in the normalized contract.
Useful? React with 👍 / 👎.
|
Merged via squash.
|
…owned wrapping (openclaw#110308) * feat: normalize web search output contract * refactor(agents): promote web_search contract from a dedicated output module * fix(agents): wrap unwrapped web_search text and pass unknown provider payloads through as raw * fix(agents): gate web_search results branch on conforming rows and cover metadata fields * fix(agents): gate every provider text path at the web_search boundary * test(agents): align web_search fixtures with boundary-owned wrapping * fix(agents): make the web_search boundary own the untrusted-content envelope * fix(agents): report declared web_search errors first and align the documented contract * fix(agents): bind envelope stripping to real markers and densify result rows * fix(agents): emit canonical urls and a closed error code from web_search * fix(agents): keep structured provider error diagnostics in the wrapped message * fix(agents): satisfy production export and lint gates for the web_search contract
What Problem This Solves
web_searchspread raw provider payloads to the model: 17 bundled providers with divergent shapes (snippet vs description vs snippets arrays, string vs object citations), provider-specific extras leaking through, and no declared output contract — so Code Mode showed-> ?and models paid a raw-inspection exec before using results. Security wrapping of untrusted web text was provider-by-provider convention with nothing enforcing it at the boundary.Why This Change Was Made
New module
src/agents/tools/web-search-output.tsnormalizes every provider payload at the core boundary into a closed four-branch contract (error/results/answer/raw), declared asoutputSchemaand promoted as a complete 691-char quick-index hint.The boundary owns the untrusted-content envelope outright — no provider-controlled metadata is consulted:
wrapWebContent.new URL().href); non-http(s) or unparseable URLs are dropped (citations) or route the payload toraw(rows).publishedsurvives only in structural ISO-date shape;queryis always the requested query (provider echoes ignored); sparse arrays densified; declarederrorkeys win over empty results."provider_error"; raw provider codes/objects serialize inside the wrapped message;docsmust canonicalize as http(s).kind: "raw"(shipped compatibility preserved;data: unknownrenders via the opaque-leaf hint rule).Named tradeoffs (deliberate): provider extras (scores, related searches, inline citation offsets, model ids,
queryTerms) no longer reach the model; free-formpublishedvalues are dropped; error codes are no longer structurally differentiated.User Impact
Code Mode composes
web_searchin one exec using trusted declared fields across all providers. Prompt-injection surfaces through unwrapped provider strings, spoofedwrappedmarkers, URL-slot prose, and error-field text are closed at one owned boundary.Evidence
src/agents/tools/web-search.test.ts: 17-provider fixture table (Brave, Codex, DuckDuckGo, Exa, Firecrawl, Gemini, Grok, Kimi, MiniMax, Ollama, Parallel, Perplexity, QA Lab, SearXNG, Tavily + error + external), wrap/strip behavior, forged-envelope, sparse-array, structured-error, URL and date gates, exact hint snapshot.