Skip to content

fix: Grok web_search extracts output_text blocks at top level#20508

Merged
Takhoffman merged 2 commits intoopenclaw:mainfrom
echoVic:fix/grok-web-search-output-text-v2
Feb 20, 2026
Merged

fix: Grok web_search extracts output_text blocks at top level#20508
Takhoffman merged 2 commits intoopenclaw:mainfrom
echoVic:fix/grok-web-search-output-text-v2

Conversation

@echoVic
Copy link
Copy Markdown
Contributor

@echoVic echoVic commented Feb 19, 2026

Some xAI Responses API responses place output_text blocks directly in the output array without a message wrapper. The parser only looked for output_text inside message.content blocks, missing these top-level entries entirely.

This adds a fallback path that checks for output_text blocks at the top level of the output array, extracting text and url_citation annotations.

Includes test coverage for the new code path.

Greptile Summary

This PR fixes a parsing bug in the Grok web search tool where xAI API responses with top-level output_text blocks (not wrapped in a message) were being ignored. The fix adds a fallback path in extractGrokContent that checks for output_text blocks directly in the output array and extracts both text content and url_citation annotations.

  • Adds text and annotations fields to the GrokSearchResponse type definition to handle top-level output blocks
  • Implements fallback logic in extractGrokContent function (lines 163-179 in web-search.ts) that processes unwrapped output_text blocks
  • Includes comprehensive test coverage for the new code path
  • Maintains backward compatibility with existing message-wrapped format and deprecated output_text field

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The implementation is clean, well-tested, and maintains backward compatibility. The change is additive (only adds a fallback path), preserves existing behavior, includes appropriate type definitions, and has comprehensive test coverage for the new code path.
  • No files require special attention

Last reviewed commit: 0babd11

@openclaw-barnacle openclaw-barnacle bot added agents Agent runtime and tooling size: S labels Feb 19, 2026
echoVic and others added 2 commits February 19, 2026 20:21
Some xAI Responses API responses place output_text blocks directly in
the output array without a message wrapper. The parser only looked for
output_text inside message.content blocks, missing these top-level
entries entirely.

Add a fallback path that checks for output_text blocks at the top level
of the output array, extracting text and url_citation annotations.
@Takhoffman Takhoffman force-pushed the fix/grok-web-search-output-text-v2 branch from 0babd11 to 29eb6ed Compare February 20, 2026 02:28
@Takhoffman Takhoffman merged commit 2144850 into openclaw:main Feb 20, 2026
24 checks passed
@Takhoffman
Copy link
Copy Markdown
Contributor

PR #20508 - fix: Grok web_search extracts output_text blocks at top level (#20508)

Merged via squash.

  • Merge commit: 2144850
  • Verified: pnpm build, pnpm check, pnpm test:macmini
  • Changes made:
    M CHANGELOG.md
  • Why these changes were made:
    Autoland requires a user-facing changelog entry for this fix; this update records the top-level output_text parsing correction for Grok web_search.
  • Changelog: CHANGELOG.md updated=true required=true opt_out=false

Thanks @echoVic!
Also thanks @ereid7 and @0xRaini for the earlier Grok parser fixes in #13049 and #13547.

vignesh07 pushed a commit to pahdo/openclaw that referenced this pull request Feb 20, 2026
…aw#20508) thanks @echoVic

Verified:
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: echoVic <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
anisoptera pushed a commit to anisoptera/openclaw that referenced this pull request Feb 20, 2026
…aw#20508) thanks @echoVic

Verified:
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: echoVic <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
rodrigogs pushed a commit to rodrigogs/openclaw that referenced this pull request Feb 20, 2026
…aw#20508) thanks @echoVic

Verified:
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: echoVic <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
Hansen1018 added a commit to Hansen1018/openclaw that referenced this pull request Feb 21, 2026
…aw#20508) thanks @echoVic

Verified:
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: echoVic <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
vincentkoc pushed a commit that referenced this pull request Feb 21, 2026
… thanks @echoVic

Verified:
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: echoVic <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
vincentkoc pushed a commit that referenced this pull request Feb 21, 2026
… thanks @echoVic

Verified:
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: echoVic <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
mmyyfirstb pushed a commit to mmyyfirstb/openclaw that referenced this pull request Feb 21, 2026
…aw#20508) thanks @echoVic

Verified:
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: echoVic <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
obviyus pushed a commit to guirguispierre/openclaw that referenced this pull request Feb 22, 2026
…aw#20508) thanks @echoVic

Verified:
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: echoVic <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 1, 2026
…aw#20508) thanks @echoVic

Verified:
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: echoVic <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
(cherry picked from commit 2144850)

# Conflicts:
#	CHANGELOG.md
#	src/agents/tools/web-search.e2e.test.ts
#	src/agents/tools/web-search.ts
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 3, 2026
…aw#20508) thanks @echoVic

Verified:
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: echoVic <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
(cherry picked from commit 2144850)

# Conflicts:
#	CHANGELOG.md
#	src/agents/tools/web-search.e2e.test.ts
#	src/agents/tools/web-search.ts
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
…aw#20508) thanks @echoVic

Verified:
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: echoVic <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants