Skip to content

Conversation

@pawel-twardziak
Copy link
Contributor

Adds support for xAI's native live_search tool, enabling models to search the web for real-time information. This includes the ability to bind the live_search tool, configure search parameters, and override search parameters per request. It also allows combining live_search with custom tools.

The changes introduce the XAILiveSearchTool, XAIBuiltInTool, and XAISearchParameters types to provide better type safety and control over the search functionality.

Fixes #9465

Adds support for xAI's native `live_search` tool, enabling models to
search the web for real-time information. This includes the ability to
bind the `live_search` tool, configure search parameters, and override
search parameters per request. It also allows combining `live_search`
with custom tools.

The changes introduce the `XAILiveSearchTool`, `XAIBuiltInTool`, and
`XAISearchParameters` types to provide better type safety and control
over the search functionality.
@changeset-bot
Copy link

changeset-bot bot commented Dec 2, 2025

🦋 Changeset detected

Latest commit: a5dc397

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@langchain/xai Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@christian-bromann christian-bromann self-requested a review December 3, 2025 02:20
Introduces native Live Search capabilities, allowing users to configure various search sources such as web, news, X, and RSS feeds.

Replaces domain-based filtering with a more flexible source-based approach, providing tailored results and aligning with xAI's API updates.
Moves the XAILiveSearchTool interface definition to the live_search tool file.
This improves code organization and maintainability by grouping related
tool definitions together.
Adds an example demonstrating how to use the built-in
`xaiLiveSearch` tool with optional parameters.
This enhances clarity and provides a practical guide
for users integrating the `live_search` functionality.
@pawel-twardziak pawel-twardziak marked this pull request as ready for review December 11, 2025 00:02
Refactors the xAI provider to export the tools via a dedicated module.

This change improves code organization and makes it easier to import and use the available tools.
The `xaiLiveSearch` tool is now accessed through `tools.xaiLiveSearch` instead of direct import.
Converts snake_case `xaiLiveSearch` parameters to camelCase
for easier use and configuration.

Simplifies tool configuration by accepting user-friendly options,
and automatically translates them into the format expected by the xAI API.
Improves the xAI live search tool by adopting the `ServerTool` interface.

This change aligns with the xAI API's server-side execution model and simplifies the tool definition. It also addresses upcoming deprecation of the Live Search API.

Removes the previous `DynamicStructuredTool` implementation and adds support for specifying web, news, X, and RSS sources.
Refactors the XAI Live Search tool to directly define properties, removing the intermediate `searchParams` object. This simplifies the tool's structure and improves readability. Also, the tool definition is updated to reflect the change from a ServerTool to a regular tool.
Updates the live search tool type to a deprecated version.

This prepares the codebase for a future transition, ensuring a smoother upgrade path.
The old tool type is replaced with "live_search_deprecated_20251215".
Refactors the README to use the `tools.xaiLiveSearch`
constructor for creating the live search tool, providing
a more accurate representation of its usage.

Corrects casing of options from camel case to camel case.
Updates the XAI Live Search tool to use default parameters,
simplifying its invocation and configuration.
Clarifies that the xAI Live Search tool options in TypeScript use camelCase field names, which are then mapped to snake_case field names in the underlying JSON API.

This ensures users understand the expected casing when using the tool options in TypeScript.
@pawel-twardziak
Copy link
Contributor Author

Maybe good to test it with a real connection?

Updates the XAI provider to use constants for the live search
tool type instead of hardcoding the string. This improves
consistency and maintainability.

Also introduces tests for live search utilities.
@pawel-twardziak
Copy link
Contributor Author

And I think we should move towards tool implementation in the next steps https://docs.x.ai/docs/guides/tools/overview

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@christian-bromann
Copy link
Member

Maybe good to test it with a real connection?

What do you mean by that?

And I think we should move towards tool implementation in the next steps https://docs.x.ai/docs/guides/tools/overview

Yes! Let's add more xAI tools 🙌

This change updates the versioning of the '@langchain/xai' package from patch to minor and adds native Live Search support.
@christian-bromann christian-bromann merged commit 49250c1 into langchain-ai:main Dec 12, 2025
2 checks passed
@pawel-twardziak
Copy link
Contributor Author

Maybe good to test it with a real connection?

What do you mean by that?

Do we have any integration set up so that we can test how it works with a live connection to xAI?

@christian-bromann
Copy link
Member

@pawel-twardziak I've added a key to the GitHub actions environment.

@pawel-twardziak
Copy link
Contributor Author

hi @christian-bromann I'll kick off the next work today - more tools and integration tests

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support server tool calling in @langchain/xai

2 participants