fix(web-search): handle xAI Responses API format in Grok provider#13547
Merged
steipete merged 1 commit intoopenclaw:mainfrom Feb 11, 2026
Merged
Conversation
The xAI /v1/responses API returns content in a structured format with typed output blocks (type: 'message') containing typed content blocks (type: 'output_text') and url_citation annotations. The previous code only checked output[0].content[0].text without filtering by type, which could miss content in responses with multiple output entries. Changes: - Update GrokSearchResponse type to include annotations on content blocks - Filter output blocks by type='message' and content by type='output_text' - Extract url_citation annotations as fallback citations when top-level citations array is empty - Deduplicate annotation-derived citation URLs - Update tests for the new structured return type Closes #13520
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
steipete
added a commit
that referenced
this pull request
Feb 11, 2026
Contributor
This was referenced Feb 12, 2026
john-ver
pushed a commit
to apmcoin/apmclaw
that referenced
this pull request
Mar 9, 2026
dustin-olenslager
pushed a commit
to dustin-olenslager/ironclaw-supreme
that referenced
this pull request
Mar 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Grok web_search provider returns
"No response"when the xAI API uses its newer/v1/responsesformat.Root Cause
The xAI Responses API returns output blocks with
type: 'message'containing content blocks withtype: 'output_text'andurl_citationannotations. The previous code checkedoutput[0].content[0].textwithout type filtering, which could fail with multiple output entries.Fix
type='message'and content bytype='output_text'url_citationannotations as fallback citationsGrokSearchResponsetype to include annotation fieldsTests
All 26 web-search tests pass, including 4 new/updated tests for Grok response parsing.
Closes #13520
Greptile Overview
Greptile Summary
This change updates the Grok (
grok) web_search provider to correctly parse xAI/v1/responsesoutput by selectingoutputblocks withtype: "message"andcontentblocks withtype: "output_text", and adds a fallback path that extractsurl_citationannotation URLs when top-levelcitationsare absent. Unit tests were updated/added to cover message-block parsing, annotation citation extraction (including deduplication), and deprecatedoutput_textfallback.The parsing logic lives in
src/agents/tools/web-search.tsand is exercised via the__testing.extractGrokContentexport insrc/agents/tools/web-search.test.ts.Confidence Score: 5/5
output_textfallback, and are covered by focused unit tests. No broken call sites were found beyond the updated usage inrunGrokSearch.