feat(xai): add x_search tool — search X via xAI Responses API#14541
feat(xai): add x_search tool — search X via xAI Responses API#14541Julientalbot wants to merge 4 commits into
Conversation
Extracted and standalone-ified from Jaaneek's PR NousResearch#10600 / Teknium's split PR NousResearch#10786. The x_search tool is the smallest, most self-contained piece of that work and doesn't depend on image/video generation changes, so it ships cleanly on its own while NousResearch#10786 rebases. ## What New tool `x_search` backed by xAI's built-in `x_search` Responses API tool. Searches X (Twitter) posts with configurable model, timeout, retry count, handle filtering, and citation extraction. ## Why split PR NousResearch#10786 bundles x_search + video_generation + image_generation xAI backend in ~2k lines across 8 files. Tests on that branch currently regress (mostly unrelated flake from Discord/Telegram suites on CI, plus xai_media asserts drifted vs evolving main). Shipping x_search alone gets 351 LOC of production + 207 LOC of tests into main while the heavier media pieces are rebased. Co-authored credit preserved. ## Scope - tools/x_search_tool.py — tool implementation (351 LOC) - tests/tools/test_x_search_tool.py — unit tests (207 LOC, 6 tests) - toolsets.py — add x_search to _HERMES_CORE_TOOLS + new TOOLSETS entry - hermes_cli/tools_config.py — add x_search to CONFIGURABLE_TOOLSETS Deliberately **not** changing: image_generation_tool.py, video_generation_tool.py, browser_cdp (preserved), xAI TTS wiring (already on main via NousResearch#10783). ## Tests - tests/tools/test_x_search_tool.py — 6 passed - tests/ -k toolset — 126 passed, 4 skipped - tests/ -k tools_config — 91 passed, 4 skipped - Registry smoke: x_search registered, browser_cdp preserved ## Config Reads optional `x_search` section from user config: ```yaml x_search: model: grok-4.20-reasoning # default timeout_seconds: 180 # default retries: 2 # default ``` ## Requirements Gated on `XAI_API_KEY` (already wired by PR NousResearch#10783). Co-authored-by: Jaaneek <Jaaneek@users.noreply.github.com> Co-authored-by: Teknium <127238744+teknium1@users.noreply.github.com>
Add a short subsection under xAI provider docs explaining how to enable the x_search toolset, its optional config (model/timeout/retries), and what it returns. Co-located with the other xAI wiring docs. Co-authored-by: Jaaneek <Jaaneek@users.noreply.github.com>
…apshot The TestBuiltinDiscovery snapshot test asserts that the tool discovery walks the tools/ directory and produces a set identical to a manually maintained list. Adding the new x_search tool requires updating that list — otherwise the snapshot drifts and CI fails.
ec4b892 to
585b952
Compare
|
Rebased onto current The CI failure on the previous tip was largely unrelated to this PR — 14 of the 15 failing tests were broken on The one real x_search-related failure was a snapshot test in Local validation:
Stack is now 3 commits — the original feat + docs + the registry snapshot fix. |
|
Cross-checked the rebased CI against
The 9 failing tests are strictly identical between main and this PR ( Failures are:
None of those modules are in this PR's diff. The other red checks on this PR ( Happy to rebase again if anything lands on main that fixes these — but this PR is in a state where nothing on it requires a code change from me. |
…in tool set snapshot Same snapshot fix as for x_search in PR NousResearch#14541: discovery walks the tools/ directory and the manual list must be kept in sync.
|
Thanks Julien! This functionality is already on main — |
What does this PR do?
Add a new
x_searchtool that searches X (Twitter) posts, profiles, and threads using xAI's native x_search Responses API tool. xAI is the only provider with native access to X/Twitter data.Changes
tools/x_search_tool.py(~350 LOC): Self-contained tool implementationPOST /v1/responses) withx_searchbuilt-in toolconfig.yamlunderx_search:section (model, timeout, retries)xai_http.pyfor User-Agent headertests/tools/test_x_search_tool.py(~300 LOC): 24 unit teststoolsets.py: Addx_searchto_HERMES_CORE_TOOLSandTOOLSETSdicthermes_cli/tools_config.py: Addx_searchtoCONFIGURABLE_TOOLSETSHow to Test
Requires
XAI_API_KEYset in~/.hermes/.env. Get one at https://console.x.ai/Design Decisions
config.yaml