Skip to content

fix(web-search): fix grok web search returning empty content#13956

Closed
seraphg wants to merge 1 commit intoopenclaw:mainfrom
seraphg:fix/grok-web-search-response-parsing
Closed

fix(web-search): fix grok web search returning empty content#13956
seraphg wants to merge 1 commit intoopenclaw:mainfrom
seraphg:fix/grok-web-search-response-parsing

Conversation

@seraphg
Copy link

@seraphg seraphg commented Feb 11, 2026

Problem

Grok web search via tools.web.search.provider: grok always returned 'No response'.

Root Cause

The xAI /v1/responses API returns multiple output items when web search is used:

  • output[0]: web_search_call (tool invocation, no text)
  • output[1]: message (actual response with text)

extractGrokContent() was hardcoded to read output[0].content[0].text, which is the web search tool call — it has no text content.

Fix

Find the message type output item via .find() instead of assuming index 0. Added fallbacks for non-search responses and the legacy output_text field.

Testing

Verified with live xAI API — search queries now return full content with citations.

Greptile Overview

Greptile Summary

This change updates Grok (xAI /v1/responses) web-search parsing to pull the assistant text from the output[] item with type === "message", instead of assuming output[0] contains text. It also keeps a fallback to the first output item for non-search responses and preserves support for the legacy output_text field.

Overall, the change is localized to extractGrokContent() in src/agents/tools/web-search.ts and aligns with the described xAI response shape when web search is enabled (tool call item followed by message item).

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • The change is small, isolated to Grok response text extraction, and adds a more correct selection of the message output item while preserving existing fallbacks. No breaking interface changes or broader behavioral changes were found in the diff.
  • No files require special attention

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

@openclaw-barnacle openclaw-barnacle bot added the agents Agent runtime and tooling label Feb 11, 2026
The xAI Responses API returns multiple output items:
- output[0]: web_search_call (tool use, no text content)
- output[1]: message (contains the actual response text)

extractGrokContent was reading output[0] which is the web_search_call
item with no text, causing all grok web searches to return 'No response'.

Fix: find the 'message' type output item instead of assuming output[0].
Keep fallbacks for non-search responses and legacy output_text field.
@seraphg seraphg force-pushed the fix/grok-web-search-response-parsing branch from 092836c to 76f37f8 Compare February 11, 2026 09:05
@octalmage
Copy link

related: #13648

TWFBusiness added a commit to TWFBusiness/openclaw-tw that referenced this pull request Feb 11, 2026
- openclaw#14019: prevent cron jobs from skipping execution (nextRunAtMs regression)
- openclaw#13931: drain active agent turns before gateway restart
- openclaw#14023: filter skills watcher file types to prevent FD exhaustion
- openclaw#13983: use requested agentId for isolated cron job auth resolution
- openclaw#13956: fix Grok web search returning empty content (xAI Responses API)
- openclaw#14018: auto-remind AI to check workspace context files on session reset
- openclaw#13960: preserve structured config validation errors in UI
- openclaw#13951: improve provider error logging in gateway logs
- openclaw#14021: optional memory flush before manual /compact command

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@sebslight
Copy link
Member

Closing as duplicate of #13327. If this is incorrect, please contact us.

@sebslight sebslight closed this Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments