Skip to content

fix: send xAI Responses native web search - #10170

Open
iuiu-py wants to merge 1 commit into
AstrBotDevs:masterfrom
iuiu-py:fix/9723-xai-responses-native-search
Open

iuiu-py wants to merge 1 commit into
AstrBotDevs:masterfrom
iuiu-py:fix/9723-xai-responses-native-search

Conversation

@iuiu-py

@iuiu-py iuiu-py commented Sep 21, 2026

Copy link
Copy Markdown

Motivation

Fixes #9723.

The xAI template now uses the openai_responses adapter, but xai_native_search was still displayed only for the legacy xai_chat_completion adapter. In addition, the Responses provider did not add the native web_search tool, so recent-information requests could not use xAI web search.

Changes

  • Allow the xai_native_search condition to match either the legacy xAI adapter or the Responses adapter.
  • Extend the shared configuration condition evaluators so an array value means "match any" while different condition keys remain ANDed.
  • When native search is enabled for an xAI provider, add {"type": "web_search"} to Responses requests in both non-streaming and streaming paths.
  • Preserve existing function tools and avoid adding duplicate web_search tools.
  • Update the native search hint in all supported dashboard locales.

Testing

  • Added failing-first tests for the provider metadata condition, non-streaming request tools, and streaming request tools.
  • uv run pytest tests/test_openai_responses_source.py -q — 11 passed.
  • uv run ruff format --check <changed Python files> and uv run ruff check <changed Python files> — passed.
  • cd dashboard && npx pnpm@10 run typecheck — passed.
  • git diff --check — passed.

Summary by Sourcery

Enable xAI native web search for the Responses adapter and expose its configuration consistently across the dashboard.

New Features:

  • Enable native xAI web search for OpenAI Responses requests in both streaming and non-streaming modes.

Bug Fixes:

  • Fix visibility of the xAI native search option for providers using the Responses adapter.
  • Prevent duplicate native web-search tools while preserving configured function tools.

Enhancements:

  • Allow configuration conditions to match any of several values while retaining AND semantics across condition keys.

Documentation:

  • Update the xAI native search hint across supported dashboard locales.

Tests:

  • Add coverage for xAI Responses metadata visibility and native search tools in streaming and non-streaming requests.

Expose the native search option for both xAI provider types and inject the Responses API web_search tool in non-streaming and streaming requests. Also allow config display conditions to accept a list of matching values.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Needs a human reviewer. When the setting is enabled for an xAI Responses provider, every affected request can invoke xAI Web Search and incur on-demand search charges, in addition to changing the request's external behavior. Reverting stops future calls but cannot undo charges already incurred.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

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.

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

1 participant