Skip to content

feat(web-search): remove built-in web_search tool, replace with MCP-based approach#3502

Merged
LaZzyMan merged 9 commits into
QwenLM:mainfrom
LaZzyMan:feat/glm-web-search-provider
Apr 24, 2026
Merged

feat(web-search): remove built-in web_search tool, replace with MCP-based approach#3502
LaZzyMan merged 9 commits into
QwenLM:mainfrom
LaZzyMan:feat/glm-web-search-provider

Conversation

@LaZzyMan

@LaZzyMan LaZzyMan commented Apr 21, 2026

Copy link
Copy Markdown
Collaborator

TLDR

Remove the entire built-in web_search tool and its provider infrastructure (DashScope, Tavily, Google, GLM), and replace with an MCP-based approach. Web search is now provided by connecting to external MCP servers, giving users full flexibility to choose their preferred search service.

This resolves a fundamental design issue: the built-in tool required maintaining provider-specific integrations and API key plumbing for each search service, while MCP already provides a cleaner, more extensible mechanism for exactly this kind of external capability.

What Changed

Removed (~1,700 lines deleted):

  • packages/core/src/tools/web-search/ — entire directory (tool logic, 4 providers, tests)
  • packages/cli/src/config/webSearch.ts — provider resolution and CLI arg wiring
  • All webSearch config schema, --*-api-key CLI flags, and env var forwarding for search providers
  • integration-tests/cli/web_search.test.ts

Updated docs:

  • docs/developers/tools/web-search.md — rewritten to document MCP-based web search setup (Alibaba Cloud Bailian, Tavily, GLM WebSearch Prime)
  • docs/developers/tools/introduction.md — moved web search from built-in tools list to MCP section
  • docs/developers/roadmap.md — updated WebSearch entry to reflect MCP approach
  • docs/users/configuration/settings.md — removed advanced.tavilyApiKey, TAVILY_API_KEY env var, --tavily-api-key CLI flag

Recommended MCP Web Search Services

Service MCP URL Auth
Alibaba Cloud Bailian WebSearch https://dashscope.aliyuncs.com/api/v1/mcps/WebSearch/mcp DASHSCOPE_API_KEY
Tavily https://mcp.tavily.com/mcp/?tavilyApiKey=<key> API key in URL
GLM WebSearch Prime https://open.bigmodel.cn/api/mcp/web_search_prime/mcp GLM_API_KEY

Quick setup (Tavily example):

qwen mcp add tavily -t http "https://mcp.tavily.com/mcp/?tavilyApiKey=${TAVILY_API_KEY}"

Or via settings.json:

{
  "mcpServers": {
    "tavily": {
      "httpUrl": "https://mcp.tavily.com/mcp/?tavilyApiKey=${TAVILY_API_KEY}"
    }
  }
}

Testing Matrix

🍏 🪟 🐧
npm run
npx
Docker

Linked issues / bugs

Closes #3496

- Add GlmProvider class implementing BaseWebSearchProvider using the
  ZhipuAI Web Search API (https://open.bigmodel.cn/api/paas/v4/web_search)
- Support multiple search engines: search_std, search_pro, search_pro_sogou,
  search_pro_quark
- Support optional config: maxResults, searchIntent, searchRecencyFilter,
  contentSize, searchDomainFilter
- Truncate query to 70 characters per API limit
- Register 'glm' in the provider discriminated union (types.ts) and
  createProvider() switch (index.ts)
- Add GlmProviderConfig to settingsSchema, ConfigParams, and Config class
- Add --glm-api-key CLI flag and GLM_API_KEY env var support in webSearch.ts
- Forward GLM_API_KEY in sandbox environment
- Update provider priority list: Tavily > Google > GLM > DashScope
- Add 17 unit tests for GlmProvider and 4 integration tests in index.test.ts
- Update docs/developers/tools/web-search.md with GLM configuration,
  env vars, CLI args, pricing, and corrected DashScope billing info
- Fix stale OAuth/free-tier references in web-search.md

Closes QwenLM#3496
wenshao
wenshao previously approved these changes Apr 21, 2026

@wenshao wenshao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found. LGTM! ✅ — gpt-5.4 via Qwen Code /review

@tanzhenxin tanzhenxin added the type/feature-request New feature or enhancement request label Apr 21, 2026
@wenshao

wenshao commented Apr 21, 2026

Copy link
Copy Markdown
Collaborator

感谢提交!在本地做了完整的验证,结果如下。

✅ 验证通过

  • TypeScript 类型检查:packages/corepackages/cli 均 0 错误(注:需要先 npm run build 重建 core 刷新 .d.ts,否则 cli 那边会在 webSearch.ts 报 stale-artifact 假错)。
  • 单元测试:glm-provider.test.ts 13/13 + index.test.ts 13/13 全部通过。
  • 真实 API 端到端:用自己的 GLM_API_KEY 实测 search_std / search_pro 引擎、searchRecencyFilter=oneWeekcontentSize=high,均正常返回,响应结构与 GlmSearchResponse 类型一致。
  • 错误分支:401 错误信息格式 [GLM] API request failed (HTTP 401): ... 符合预期;无 API key 时抛 [GLM] Provider is not available.
  • 配置全链路:settings.jsonsettingsSchemaConfigParametersConfig.webSearchcreateProviderGlmProvider,类型和运行时均对齐,discriminated union 补得完整,没有遗漏点。
  • 沙箱转发:GLM_API_KEYsandbox.ts 里正确加到 `--env`。

🔧 合入前建议修改的点

1. 文档错误(必改)— `docs/developers/tools/web-search.md:54`

新增的这句话与实现不符:

DashScope requires an Aliyun API key configured via `DASHSCOPE_API_KEY` or explicitly in the provider config

实际上 `DashScopeProvider.isAvailable()` 只判断 `authType === 'qwen-oauth'`,完全不读 `DASHSCOPE_API_KEY` 这个环境变量。用户按这句指示只设 `DASHSCOPE_API_KEY` 而没有 qwen-oauth 凭据,web search 仍然用不了,会产生误导。

建议二选一:

  • (推荐) 把这块 DashScope 相关的文案改动回滚 — 这部分跟本 PR 主旨(新增 GLM provider)无关,PR 越聚焦越好合;
  • 或改成贴近实现的措辞,比如 "DashScope web search currently requires qwen-oauth credentials; after the free-tier auto-injection was removed on 2026-04-15, it must be explicitly listed in `webSearch.provider`"。

2. 文档补充 GLM API 的服务端限制(建议改)

我实测发现 BigModel 服务端对几个参数并非硬约束,建议在 GLM 章节加一段注记,避免用户按配置的数字产生预期落差:

  • `maxResults` (底层传 `count`) 对 `search_std` / `search_pro` 不影响返回条数 — 实测 `count=1` 和 `count=10` 都返回 10 条;
  • `searchDomainFilter` 是 whitelist,但服务端并非严格限制,仍可能返回域名之外的结果(例如设 `anthropic.com` 实测返回了 sina.com.cn / qq.com)。

这些是 BigModel API 当前的行为,不是 PR 的 bug,但文档点明后用户心里有数。

3. PR 描述的数字对齐(建议改)

PR body 里写 "17 unit tests",而 `glm-provider.test.ts` 里实际是 13 个;另外 `index.test.ts` 新增了 4 个 GLM 用例。建议改成 "13 unit tests for `GlmProvider` + 4 integration tests in `index.test.ts`",按文件归属更清晰。


核心代码没问题,把以上 3 点处理掉(尤其是第 1 点)就可以合并。

…remove qwen-oauth dependency

- DashScopeProvider.isAvailable() now checks config.apiKey instead of authType
- Remove OAuth credential file reading and resource_url requirement
- Use standard DashScope endpoint: dashscope.aliyuncs.com/api/v1/indices/plugin/web_search
- Read DASHSCOPE_API_KEY env var and --dashscope-api-key CLI flag
- Forward DASHSCOPE_API_KEY into sandbox environment
- Update integration test to detect DASHSCOPE_API_KEY
- Update docs to reflect new API key based configuration
The web_search tool and all related provider implementations are removed.
Web search functionality will be provided via MCP integrations instead,
which is the direction the broader agent ecosystem is moving.

Removed:
- packages/core/src/tools/web-search/ (entire directory)
- packages/cli/src/config/webSearch.ts
- integration-tests/cli/web_search.test.ts
- ToolNames.WEB_SEARCH, ToolErrorCode.WEB_SEARCH_FAILED
- webSearch config in ConfigParams, Config class, settingsSchema
- CLI options: --tavily-api-key, --google-api-key, --google-search-engine-id,
  --glm-api-key, --dashscope-api-key, --web-search-default
- Sandbox env forwarding for TAVILY/GLM/DASHSCOPE/GOOGLE search keys
- web_search from rule-parser, permission-manager, speculation gate,
  microcompact tool set, and builtin-agents tool list
@LaZzyMan LaZzyMan changed the title feat(web-search): add GLM (ZhipuAI) web search provider feat(web-search): remove built-in web_search tool, replace with MCP-based approach Apr 22, 2026
@LaZzyMan

Copy link
Copy Markdown
Collaborator Author

Test MCP servers installed following guide in new docs:

Bailian:
image

Travily (Both http & npx):
image

GLM:
image

pomelo-nwu
pomelo-nwu previously approved these changes Apr 22, 2026

@pomelo-nwu pomelo-nwu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread packages/core/src/extension/claude-converter.ts Outdated
Comment thread packages/webui/src/components/toolcalls/WebFetchToolCall.tsx

@wenshao wenshao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] packages/core/src/skills/bundled/qc-helper/SKILL.md:121 still lists webSearch under advanced config keys after this PR removes the webSearch setting. Users asking qc-helper about configuration can still be guided toward a removed setting instead of MCP server configuration. Please remove webSearch from the quick reference and, if useful, point web search questions to MCP server configuration instead.

[Suggestion] docs/developers/roadmap.md:59 still lists Tool: WebSearch as an implemented built-in tool using Tavily API even though this PR removes the built-in implementation. Please update the entry to reflect MCP-based web search, or mark the old built-in WebSearch item as removed/deprecated.

— gpt-5.5 via Qwen Code /review

Comment thread packages/webui/src/components/toolcalls/WebFetchToolCall.tsx
@LaZzyMan LaZzyMan dismissed wenshao’s stale review April 24, 2026 03:27

suggestions will be fixed in future

@pomelo-nwu pomelo-nwu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LaZzyMan LaZzyMan merged commit aeeb297 into QwenLM:main Apr 24, 2026
13 checks passed
xaelistic pushed a commit to xaelistic/qwen-code that referenced this pull request Jun 7, 2026
…ased approach (QwenLM#3502)

* feat(web-search): add GLM (ZhipuAI) web search provider

- Add GlmProvider class implementing BaseWebSearchProvider using the
  ZhipuAI Web Search API (https://open.bigmodel.cn/api/paas/v4/web_search)
- Support multiple search engines: search_std, search_pro, search_pro_sogou,
  search_pro_quark
- Support optional config: maxResults, searchIntent, searchRecencyFilter,
  contentSize, searchDomainFilter
- Truncate query to 70 characters per API limit
- Register 'glm' in the provider discriminated union (types.ts) and
  createProvider() switch (index.ts)
- Add GlmProviderConfig to settingsSchema, ConfigParams, and Config class
- Add --glm-api-key CLI flag and GLM_API_KEY env var support in webSearch.ts
- Forward GLM_API_KEY in sandbox environment
- Update provider priority list: Tavily > Google > GLM > DashScope
- Add 17 unit tests for GlmProvider and 4 integration tests in index.test.ts
- Update docs/developers/tools/web-search.md with GLM configuration,
  env vars, CLI args, pricing, and corrected DashScope billing info
- Fix stale OAuth/free-tier references in web-search.md

Closes QwenLM#3496

* docs(web-search): fix DashScope note and add GLM server-side limitations

* fix(web-search): make DashScope provider work with standard API key, remove qwen-oauth dependency

- DashScopeProvider.isAvailable() now checks config.apiKey instead of authType
- Remove OAuth credential file reading and resource_url requirement
- Use standard DashScope endpoint: dashscope.aliyuncs.com/api/v1/indices/plugin/web_search
- Read DASHSCOPE_API_KEY env var and --dashscope-api-key CLI flag
- Forward DASHSCOPE_API_KEY into sandbox environment
- Update integration test to detect DASHSCOPE_API_KEY
- Update docs to reflect new API key based configuration

* feat(web-search): remove built-in web search tool

The web_search tool and all related provider implementations are removed.
Web search functionality will be provided via MCP integrations instead,
which is the direction the broader agent ecosystem is moving.

Removed:
- packages/core/src/tools/web-search/ (entire directory)
- packages/cli/src/config/webSearch.ts
- integration-tests/cli/web_search.test.ts
- ToolNames.WEB_SEARCH, ToolErrorCode.WEB_SEARCH_FAILED
- webSearch config in ConfigParams, Config class, settingsSchema
- CLI options: --tavily-api-key, --google-api-key, --google-search-engine-id,
  --glm-api-key, --dashscope-api-key, --web-search-default
- Sandbox env forwarding for TAVILY/GLM/DASHSCOPE/GOOGLE search keys
- web_search from rule-parser, permission-manager, speculation gate,
  microcompact tool set, and builtin-agents tool list

* fix: remove websearch reference

* docs: remove websearch tool

* docs: add break change guide

* fix review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/feature-request New feature or enhancement request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

webSearch功能,在免费份额停掉以后是不是也无法使用了

4 participants