Skip to content

feat(websearch): add provider-native hosted search tools and local search providers - #33

Merged
Blankeos merged 4 commits into
mainfrom
feat/configurable-websearch-xsearch
Aug 27, 2026
Merged

Blankeos merged 4 commits into
mainfrom
feat/configurable-websearch-xsearch

Conversation

@Blankeos

@Blankeos Blankeos commented Aug 27, 2026

Copy link
Copy Markdown
Owner

TLDR

Lets models use provider-hosted web search (OpenAI, Anthropic, xAI, OpenRouter) via websearch.native, instead of only local search adapters — plus Parallel & Tako as new local providers. websearch.x: native adds X/Twitter search (xAI only).


Add websearch.native config to enable provider-executed search tools (web search, x_search) alongside local search adapters. Introduces ToolTransport enum to distinguish client vs provider-native tools in the aisdk layer.

  • New hosted_search module with tool definitions for OpenAI, xAI, Anthropic, and OpenRouter
  • Provider-native tools are passed through as-is in request bodies (Anthropic beta header, OpenAI Responses, OpenRouter plugins)
  • native.web substitutes local websearch when provider supports it; native.x is a complement (xAI x_search)
  • Add Parallel and Tako as local websearch providers
  • Update Anthropic/OpenAI/OpenAI-compatible providers to route ProviderNative and OpenRouterPlugin transports
  • Filter hosted search SSE events from client tool accumulator in OpenAI provider
  • Update config docs with native search, cost tables, and provider table

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 27, 2026

Copy link
Copy Markdown

Deploying crabcode with  Cloudflare Pages  Cloudflare Pages

Latest commit: 10fe613
Status: ✅  Deploy successful!
Preview URL: https://4ddaac1e.crabcode.pages.dev
Branch Preview URL: https://feat-configurable-websearch.crabcode.pages.dev

View logs

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

…arch providers

Add `websearch.native` config to enable provider-executed search tools (web search, x_search) alongside local search adapters. Introduces `ToolTransport` enum to distinguish client vs provider-native tools in the aisdk layer.

- New `hosted_search` module with tool definitions for OpenAI, xAI, Anthropic, and OpenRouter
- Provider-native tools are passed through as-is in request bodies (Anthropic beta header, OpenAI Responses, OpenRouter plugins)
- `native.web` substitutes local websearch when provider supports it; `native.x` is a complement (xAI x_search)
- Add Parallel and Tako as local websearch providers
- Update Anthropic/OpenAI/OpenAI-compatible providers to route `ProviderNative` and `OpenRouterPlugin` transports
- Filter hosted search SSE events from client tool accumulator in OpenAI provider
- Update config docs with native search, cost tables, and provider table
@Blankeos
Blankeos force-pushed the feat/configurable-websearch-xsearch branch from 8bab3a8 to 9abb2b1 Compare August 27, 2026 09:02
Add `ChunkType::ProviderToolCall` to represent server-side tool lifecycle (hosted search, x_search, file_search) without entering the client tool-execute loop.

- Parse Anthropic `server_tool_use` / `web_search_tool_result` SSE events
- Parse OpenAI hosted search SSE events (web_search, x_search, file_search, custom_tool_call)
- Forward `ProviderToolCall` through subagent and response streams
- Convert provider tool payloads into UI ToolCalls / ToolResult events in `client.rs`
- Upsert tool call parts in app to handle running→completed transitions with same id
- Skip provider-executed parts when replaying message history to API
@Blankeos

Copy link
Copy Markdown
Owner Author

Also added /v1/responses for the xai provider when using grok models. Since it's the only path to display x_search in toolcall cards.

- It was sending /v1/v1/responses so it was crashing
- Map `@openrouter/ai-sdk-provider` npm package to `ProviderKind::OpenAICompatible`
- Add test verifying OpenRouter routes through the OpenAI-compatible chat completions path
… preview for provider-executed search

Hosted search completed events sometimes omit sources or wipe the query to "";
this caused the TUI to show stub previews and lose the original search arguments.

- Add `hosted_search_args_are_hollow` to detect empty/blank search args
- Add `hosted_search_output_preview` that formats sources from args when output is missing
- Prefer running tool_call args over hollow result args in both app.rs and chat.rs
- Change provider-executed tool result status from "completed" to "ok" so TUI renders output_preview
- Make `SearchItem` and `format_results` in websearch.rs pub(crate) for reuse
- Add tests for preview formatting and hollow args detection
@Blankeos

Copy link
Copy Markdown
Owner Author

Fixed a bug with openrouter as well. It was sending to /v1/v1/responses, lol. Never tried openrouter before so... Also u need a credit card to use native websearch on openrouter.

@Blankeos

Blankeos commented Aug 27, 2026

Copy link
Copy Markdown
Owner Author

PR Review: feat/configurable-websearch-xsearchmain

PR: #33 — feat(websearch): add provider-native hosted search tools and local search providers
Merge confidence: 5 / 5

Re-score — tip 10fe613. CI green (plan + Cloudflare Pages). Release jobs skipped (expected on PR).


Body (GitHub-ready)

Adds provider-executed search as first-class aisdk Tools (ToolTransport::{ProviderNative,OpenRouterPlugin}) plus websearch.native.{web,x} config.

  • Defaults: native.web = false, native.x = true (xAI-only; ignored elsewhere).
  • When native.web is on and the active provider supports hosted web, the local websearch tool is skipped.
  • Wire-up in src/llm/client.rs and src/agent/subagent.rs; Anthropic hosted web + beta header; OpenAI Responses hosted events; OpenRouter plugins: [{id:"web"}].
  • Docs: _docs/config/websearch.mdx (+ index).

No DB/auth migrations. cargo check --bins and check-aisdk-boundary passed locally. Author smoked OpenAI / Anthropic / xAI / OpenRouter (no live subscription re-test in this review). Working tree may still have uncommitted edits beyond HEAD — confirm PR tip matches what you smoked.


Regressions?

Likely intentional behavior shifts (not silent breakage):

  1. xAI default gains x_searchnative.x defaults on whenever websearch.enabled is true. Existing xAI sessions get a new provider tool without config changes.
  2. native.web = true replaces local websearch on xAI / OpenAI / Anthropic / OpenRouter (should_register_local_websearch). Mis-set config → no Exa/etc. backend.
  3. Anthropic always sends anthropic-beta: …web-search-… when the hosted web tool is attached; unsupported models/accounts may error at request time.
  4. OpenRouter attaches plugins for web; behavior/cost depends on OpenRouter + underlying model.

Mitigations already in the branch: SSE/event filtering for hosted vs client tool calls (OpenAI Responses + Anthropic server blocks); unit coverage around config parse and hosted tool selection; aisdk keeps host policy out of the SDK (HostedSearchSelection).

Watch / dirty tree: Local uncommitted changes touch openai.rs, chunk.rs, response.rs, app.rs, etc. Confirm those land in the PR before merge so review matches CI.

No evidence of persistence/schema regressions (no src/persistence diff).


Migrations?

No. No SQLite/prefs/auth schema changes; config is JSON-only (websearch.native). Nothing to migrate for existing users.


Checklist before merge

  • Smoke OpenAI / Anthropic / xAI / OpenRouter (author done; OpenRouter /v1/v1 fixed via OpenAICompatible).
  • PR tip clean — local HEAD == origin == 10fe613 (only untracked: this review file).
  • CI green on feat(websearch): add provider-native hosted search tools and local search providers #33plan + Cloudflare Pages pass; release publish jobs skipped (expected on PR).
  • native.web / native.x defaults confirmed good; docs look good.
  • Hosted preview uses shared format_results (Search provider: native / native (x)).
  • Optional: release note on hosted-search cost/latency + xAI x_search default.

Confidence bumps

N/A — 5 / 5. Optional release note is polish, not a confidence gate.

@Blankeos
Blankeos merged commit f696efc into main Aug 27, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant