fix: upgrade xAI web search from deprecated Live Search to Responses API#12812
fix: upgrade xAI web search from deprecated Live Search to Responses API#12812kangfenmao merged 11 commits intoCherryHQ:mainfrom
Conversation
Upgrade @ai-sdk/xai from 2.0.36 to 2.0.56 and switch xAI provider to use the Responses API with tool-based web search instead of the deprecated Live Search approach using provider options. Changes: - Upgrade @ai-sdk/xai to 2.0.56 (ai-v5 compatible) - Switch xAI provider to use xai.responses(modelId) by default - Change web search plugin from searchParameters to xai.tools.webSearch() - Simplify xAI web search config to use only excludedDomains (max 5) - Remove unused createXaiOptions function - Update tests to match new config format Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
|
Hi maintainers, this PR is ready for review. Could someone please take a look |
GeorgeDong32
left a comment
There was a problem hiding this comment.
This PR correctly implements the migration from deprecated xAI Live Search API to the new Responses API. The code quality is excellent with reduced complexity and better performance.
However, there are two documentation issues that should be addressed before merging:
1. Breaking changes not fully documented
The PR introduces breaking changes (default configuration changes), but the "Breaking changes" section in the PR description is empty.
Suggestion: Add the following to the PR description:
### Breaking changes
- xAI web search default configuration changed from using `searchParameters` to `xai.tools.webSearch()`
- Previous default settings (returnCitations, maxSources, sources) are no longer applied by default
- Users requiring custom xAI search behavior should update their web search configuration2. Release Note missing
The PR description has an empty Release Note, but this is a user-visible feature change.
Suggestion: Add a Release Note:
```release-note
Upgraded xAI provider to use the new Responses API with tool-based web search.
The deprecated Live Search approach has been removed.
xAI web search now uses `xai.tools.webSearch()` with simplified configuration.
---
**Overall**: The code changes are good and ready to merge. Please update the PR description with the missing documentation sections.
EurFelux
left a comment
There was a problem hiding this comment.
Review Summary
整体来看,这个 PR 将 xAI web search 从已弃用的 Live Search (provider options 方式) 迁移到 Responses API (tool-based 方式),方向正确,代码质量良好。
👍 做得好的地方
- 类型系统升级:
XAISearchConfig从ProviderOptionsMap['xai']['searchParameters']改为Parameters<typeof xai.tools.webSearch>[0],直接从 SDK 推导类型,更安全也更易维护 - 一致性: xAI 现在和 OpenAI、Anthropic、Google 一样使用
applyToolBasedSearch,而不是走applyProviderOptionsSearch的特殊路径 - 清理干净:
createXaiOptions删除后无残留引用,ProviderOptionsMap的导入也一并清理 - 测试更新: 测试用例完整覆盖了新的配置格式(空配置、有 excludeDomains、超过 5 个域名截断)
- 符合 API 文档: xAI Responses API 的
web_searchtool 确实只支持excludedDomains/allowedDomains(最多 5 个),代码实现与官方文档一致
⚠️ 需要关注的点
- 所有 xAI 模型默认走 Responses API —
schemas.ts中将languageModel重定向到provider.responses(modelId),这是一个全局行为变更,需要确认所有 xAI 模型都支持 Responses API maxResults对 xAI 不再生效 — 用户之前配置的搜索结果数量限制会被静默忽略,建议在代码中加个注释说明原因- PR 描述的 Breaking Changes 和 Release Note 部分为空 — 同意 @GeorgeDong32 的建议,应补充这些信息
📝 Minor
excludeDomains.slice(0, 5)比之前的excludeDomains.slice(0, Math.min(excludeDomains.length, 5))更简洁 👌
| maxSearchResults: 5, | ||
| sources: [{ type: 'web' }, { type: 'x' }, { type: 'news' }] | ||
| }, | ||
| xai: {}, |
There was a problem hiding this comment.
Observation: Default xAI web search config is now empty
The old default config had explicit settings:
xai: {
mode: 'on',
returnCitations: true,
maxSearchResults: 5,
sources: [{ type: 'web' }, { type: 'x' }, { type: 'news' }]
}Now it's just xai: {}. This delegates all behavior to xAI's server-side defaults for the Responses API web_search tool, which is cleaner — but it means users lose the ability to control maxSearchResults and source types (web, x, news) that were previously configurable.
Is this intentional? The xAI Responses API web_search tool currently only supports excludedDomains and allowedDomains as parameters, so this simplification aligns with the new API surface. Just flagging the behavioral difference.
|
Note This comment was translated by Claude. Hey friends, could a real person please review my PR? Why are all the reviews from AI? Original Content朋友们,有没有真人review一下我的pr,怎么都是AI在review |
|
Note This comment was translated by Claude. After upgrading to the response API, the xAI provider type needs to be modified. Original Content升级成response api之后,需要修改xai的provider 类型 |
|
Note This comment was translated by Claude. It still shows chat/completion here. Original Content这里还显示的是 chat/completion |
Resolve @ai-sdk/* package version conflicts by adopting main's v3/v4 versions while preserving the PR's xAI Responses API wrapper. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Register both webSearch and xSearch tools when xAI provider is used, enabling X/Twitter post search alongside web search. Update config types and tests accordingly. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add x_search (and non-prefixed web_search) to the tool renderer so xAI provider search results are visible in the message view. Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Fix webSearchSource falling back to 'ai-sdk' for xAI by passing providerId to AiSdkToChunkAdapter as fallback when providerMetadata is empty (xAI responses API behavior) - Add 'xai' -> GROK mapping in sourceMap for provider identification - Split GROK and OPENROUTER citation formatting in messageBlock.ts; GROK now falls back to hostname when title is just a number - Add GROK case in normalizeCitationMarks to handle [[N]](url) format - Add X oEmbed API integration (publish.x.com/oembed) for fetching tweet content in citation tooltips and citation panel - Enrich CitationTooltip with lazy oEmbed loading for x.com post URLs Co-Authored-By: Claude Opus 4.6 <[email protected]>
GeorgeDong32
left a comment
There was a problem hiding this comment.
Code Review Summary
This PR correctly implements the migration from deprecated xAI Live Search API to the new Responses API with tool-based web search. The code quality is excellent.
Strengths
- Type system upgrade: Uses SDK-derived types instead of manual type definitions
- API consistency: xAI now uses
applyToolBasedSearchlike other providers - Clean removal:
createXaiOptionsdeleted without residual references - Complete tests: New config format fully covered
- Good fallback handling:
providerIdfallback inAiSdkToChunkAdapter - User experience: X oEmbed API integration for tweet content display
Minor Fix Needed
One small issue: The migration log says "migrate 199 error" but should say "migrate 200 error" in src/renderer/src/store/migrate.ts:3267. This doesn't affect functionality.
Verdict
Approved - Ready to merge.
Co-authored-by: George·Dong <[email protected]>
EurFelux
left a comment
There was a problem hiding this comment.
Follow-up Review
在之前几位 reviewer 的基础上补充一些发现喵~
整体评价
PR 的核心变更(从 Live Search 迁移到 Responses API)是正确的方向,代码质量良好。同意 @GeorgeDong32 和 @DeJeune 的 approval。
新发现
-
CitationsList.tsx中的displayTitle逻辑有隐患 — 用fetchedContent.split(':')[0]从已拼接+截断的字符串中反向提取 author 不够可靠。建议参考CitationTooltip.tsx的做法,直接用oembedData获取 author。 -
isXPostUrl缺少www.twitter.com— 小问题但会导致部分旧 Twitter 链接不被识别。 -
migrate.ts的 typo — 同意 @GeorgeDong32 的发现,'migrate 199 error'应该改为'migrate 200 error'。
已确认没有问题的点
- ✅
customProvider的...providerspread 保留了textEmbeddingModel、imageModel等方法 - ✅
AiSdkToChunkAdapter的providerId参数位置正确(第 7 个参数) - ✅ web search tool 的
applyToolBasedSearch调用方式与 OpenAI/Anthropic/Google 一致 - ✅ Citation 格式化中 GROK case 与 OPENROUTER case 正确分离
- ✅ Grok citation mark 格式
[[N]](url)的正则处理正确 - ✅ 测试覆盖完整
Avoid reverse-parsing author from concatenated+truncated fetchedContent
string via split(':'), which breaks if author name or tweet text contains
colons. Use a dedicated oEmbed query (matching CitationTooltip.tsx pattern)
to derive displayTitle reliably.
Also handle www.twitter.com in isXPostUrl by stripping the www prefix.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: suyao <[email protected]>
CitationTooltip now uses useQuery for oEmbed data, so tests need a QueryClientProvider wrapper to avoid "No QueryClient set" errors. Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: suyao <[email protected]>
|
test failed |
Signed-off-by: suyao <[email protected]>
### What this PR does Before this PR: - Version is 1.7.24 After this PR: - Version is 1.7.25 - Release notes updated in `electron-builder.yml` ### Why we need it and why it was done in this way Standard release workflow: collect commits since v1.7.24, generate bilingual release notes, bump version. The following tradeoffs were made: N/A The following alternatives were considered: N/A ### Breaking changes **Action Required**: The built-in filesystem MCP server now requires manual approval for write/edit/delete operations by default. ### Special notes for your reviewer **Included commits since v1.7.24:** ✨ New Features: - feat(websearch): add Querit search provider (#13050) - feat(minapp,provider): add MiniMax Agent, IMA mini apps and MiniMax Global, Z.ai providers (#13099) - feat(provider): add agent support filter for provider list (#11932) - feat(agent): add custom environment variables to agent configuration (#13357) - feat: add GPT-5.4 support (#13293) - feat(gemini): add thought signature persistence (#13100) 🐛 Bug Fixes: - fix: secure built-in filesystem MCP root handling (#13294) - fix: check underlying tool permissions for hub invoke/exec (#13282) - fix: remove approval countdown timers and add system notifications (#13281) - fix: agent tool status not stopping on abort (#13111) - fix: resolve spawn ENOENT on Windows for Code Tools (#13405) - fix: Use default assistant for topic auto-renaming (#13387) - fix(backup): defer auto backup during streaming response (#13307) - fix(ui): fix Move To submenu overflow (#13399) - fix: render xml fenced svg blocks as svg previews (#13431) - fix: correct Gemini reasoning params (#13388) - fix: improve Qwen 3.5 reasoning model detection (#13235) - fix: upgrade xAI web search to Responses API (#12812) - fix(api-server): relax chat completion validation (#13279) - fix: install or uninstall button state issues (#13114) - fix: improve update dialog behavior (#13363) - fix: auto-convert reasoning_effort to reasoningEffort (#12831) ### Checklist - [x] PR: The PR description is expressive enough and will help future contributors - [x] Code: Write code that humans can understand and Keep it simple - [x] Refactor: You have left the code cleaner than you found it (Boy Scout Rule) - [x] Upgrade: Impact of this change on upgrade flows was considered and addressed if required - [x] Documentation: A user-guide update was considered and is present (link) or not required. - [x] Self-review: I have reviewed my own code before requesting review from others ### Release note ```release-note See release notes in electron-builder.yml ``` --------- Signed-off-by: kangfenmao <[email protected]>
What this PR does
Upgrades
@ai-sdk/xaifrom 2.0.36 to 2.0.56 and migrates xAI web search from the deprecated Live Search (provider options) approach to the Responses API with tool-based web search (xai.tools.webSearch()+xai.tools.xSearch()).Before this PR:
searchParametersprovider optionsAfter this PR:
xai.responses(modelId)withxai.tools.webSearch()andxai.tools.xSearch()x_searchtool renderingpublish.x.com/oembed)isXPostUrlhandles all hostname variants (x.com,www.x.com,twitter.com,www.twitter.com)Why we need it and why it was done in this way
xAI deprecated the Live Search approach in favor of the Responses API with explicit tool calls. This migration:
xai.responses()+xai.tools.webSearch()/xai.tools.xSearch()patternexcludedDomains(max 5)CitationTooltip.tsxandCitationsList.tsxThe following tradeoffs were made:
useQuery(cache key['xOembed', url]) shared across components to avoid duplicate requests while keeping the author display title reliable (no string parsing from truncated content)Breaking changes
None. The migration is transparent to users — web search continues to work with the same UI, now with richer X/Twitter citation support.
Special notes for your reviewer
webSearchSourcedetection was updated to handle xAI's Responses API behavior whereproviderMetadatamay be empty — falls back toproviderIdnormalizeCitationMarksnow handles the[[N]](url)format from GROKtitleis just a numberChecklist
Release note