Skip to content

[Bug] xAI Responses provider does not expose or send the native web_search tool. #9723

Description

@Technistretron

问题描述

Hello, and thank you for implementing the generic Responses API provider. But the websearch function of the provider XAi, still cant work in the newest version. I tested it in the Astrbot desktop version V4.27.2 for windows amd64, and it remains in v4.27.3. Last week i submitted this bug in pull request [#9515 ]. As u maid ignore the merged branch, so i repeat it here.

I retested the official xAI provider with AstrBot / AstrBot Desktop v4.27.2. Based on the current source code and the actual request behavior, #9515 has implemented support for the Responses API endpoint, message conversion, reasoning history, and function calling. However, it appears that the native xAI Web Search requested in #7697 has not been fully implemented.

Test environment

  • AstrBot: v4.27.2
  • AstrBot Desktop: v4.27.2
  • Provider: Official xAI
  • Provider type: openai_responses
  • API Base URL: https://api.x.ai/v1
  • Model: grok-4.5

Actual behavior

After upgrading and creating a new xAI provider:

  1. The Enable Native Search option is no longer displayed in the xAI provider configuration.
  2. grok-4.5 can generate normal responses through the Responses API.
  3. Requests for recent news do not trigger xAI Web Search.
  4. The response contains no verifiable real-time search results.
  5. The same model and API key can access native Web Search correctly in other clients that support xAI Responses Web Search.

For example:

Please use Web Search to find three international news stories from the past 24 hours.
For each story, provide the source name, publication time, and full URL.

xai_native_search is still restricted to the legacy adapter

The current configuration is:

"xai_native_search": {
    "description": "启用原生搜索功能",
    "type": "bool",
    "hint": "启用后,将通过 xAI 的 Chat Completions 原生 Live Search 进行联网检索(按需计费)。仅对 xAI 提供商生效。",
    "condition": {
        "provider": "xai",
        "type": "xai_chat_completion",
    },
}

Source:

https://github.com/AstrBotDevs/AstrBot/blob/v4.27.2/astrbot/core/config/default.py#L2020-L2027

Because newly created xAI providers now use openai_responses, this condition is not satisfied, and the Dashboard hides the native search option.

According to the xAI documentation, using the /v1/responses endpoint alone does not automatically enable Web Search. The request must explicitly include:

{
  "tools": [
    {
      "type": "web_search"
    }
  ]
}

xAI documentation:

https://docs.x.ai/developers/tools/web-search

Therefore, it appears that #9515 successfully added the generic Responses API provider, but the xAI-specific server-side web_search tool is still missing.

Screenshot

image

如何复现?

Environment

  • AstrBot: v4.27.3
  • AstrBot Desktop: v4.27.3 for Windows amd64
  • Provider: Official xAI
  • Provider type: openai_responses
  • API Base URL: https://api.x.ai/v1
  • Model: grok-4.5
  • Third-party Web Search plugins: Disabled

The same issue was also reproduced in v4.27.2.

Steps to reproduce

  1. Install or upgrade to AstrBot Desktop v4.27.3.

  2. Open the AstrBot Dashboard.

  3. Delete any previously configured xAI provider.

  4. Create a new provider using the official xAI provider template. This avoids retaining settings from the legacy adapter.

  5. Configure it as follows:

    Provider: xAI
    Provider type: openai_responses
    API Base URL: https://api.x.ai/v1
    Model: grok-4.5
    
  6. Open the configuration page of the newly created xAI provider.

  7. Observe that the Enable Native Search (xai_native_search) option is not displayed.

  8. Save and enable the provider.

  9. Start a new conversation and send the following prompt:

    You must use Web Search before answering.
    
    Find three international news stories published within the past 24 hours.
    For each story, provide:
    1. The headline
    2. The source name
    3. The exact publication time
    4. The full source URL
    
    Do not answer from prior knowledge.
    
  10. Observe that the model returns a normal response, but native xAI Web Search is not invoked. The response contains no reliable real-time search results or verifiable search citations.

  11. If HTTP request logging is enabled, inspect the outgoing POST /v1/responses request. The request does not include the xAI server-side Web Search tool:

    {
      "tools": [
        {
          "type": "web_search"
        }
      ]
    }

Actual behavior

  • The official xAI provider can generate normal responses through the Responses API.
  • The Enable Native Search option is missing.
  • Requests requiring current information do not invoke xAI Web Search.
  • No verifiable real-time search citations are returned.
  • The request sent through AstrBot does not include the server-side web_search tool.

Expected behavior

AstrBot should expose an option to enable native xAI Web Search when the xAI provider uses openai_responses.

When enabled, AstrBot should include the following tool in the request to POST /v1/responses:

{
  "tools": [
    {
      "type": "web_search"
    }
  ]
}

The response should contain current Web Search results and citations returned by xAI.

Control test

Using the same API key, API Base URL, and model in another Responses API client works correctly when the request explicitly includes:

{
  "tools": [
    {
      "type": "web_search"
    }
  ]
}

This suggests that the API key, model, account permissions, and network connection are working, and that the issue is specific to AstrBot's openai_responses provider.

AstrBot 版本

v4.27.3

操作系统

Windows

部署方式

Windows Desktop

使用的消息平台适配器

QQ官方机器人以及Astrbot Desktop chat功能。

错误日志

Sanitized reproduction log


AstrBot Desktop version: 4.27.3
Operating system: Windows amd64
Test date: 2026-08-18 (UTC+8)
Provider: xAI
Provider adapter: openai_responses
Model: grok-4.5


### AstrBot backend log


[10:28:12.372] [Core] [INFO] [core.core_lifecycle:365]: AstrBot started.
[10:29:34.013] [Core] [INFO] [provider.manager:656]: Loading model openai_responses(xai/grok-4.5) ...
[10:29:56.604] [Core] [INFO] [services.live_chat_service:184]: [Live Chat] WebSocket connected: astrbot
[10:29:56.624] [Core] [INFO] [core.event_bus:74]: [default] [webchat(webchat)] astrbot/astrbot: 请帮我总结收集今日中国要闻
[10:29:56.727] [Core] [INFO] [respond.stage:206]: Prepare to send - astrbot/astrbot:
[10:29:56.727] [Core] [INFO] [respond.stage:223]: Applying streaming output (webchat).
[10:30:01.406] [Core] [INFO] [core.astr_main_agent:1131]: Generated chatui title: 今日中国要闻总结
[10:30:06.982] [Core] [INFO] [runners.tool_loop_agent_runner:1484]: Agent execution was requested to stop by user.


### Stored WebChat transcript


[10:29:56.621] [user]
请帮我总结收集今日中国要闻

[10:30:06.985] [assistant: xAI/grok-4.5]
我这边无法实时抓取或浏览互联网新闻,所以不能直接替你汇总“2026年8月18日”的中国要闻原文与权威来源。

你若需要今日要闻,建议直接看这些相对集中、更新快的渠道:

1. 新华社 / 新华网 — 国内时政与重大发布
2. 央视新闻 / 央视网 — 电视与图文要闻
3. 人民网 — 综合国内要闻
4. 中国政府网 — 政策、国务院及部委信息

辅助信息

No response

检查清单

  • 我已在 Issue 列表中搜索过相关问题仍无法解决,或该问题从未被报告过。
  • 我已尝试过禁用所有插件,排除了可能是因插件导致的问题。
  • 我报告的问题与 AstrBot 本体相关,而非在报告某一插件的问题。
  • 我已阅读并同意本项目的贡献者行为准则
  • (可选)我愿意提交 PR 以帮助修复该问题。

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:providerThe bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions