Skip to content

fix(provider): add xai to reasoning tag provider list (#27533)#28316

Open
zeron-G wants to merge 1 commit intoopenclaw:mainfrom
zeron-G:fix/xai-reasoning-tag-provider
Open

fix(provider): add xai to reasoning tag provider list (#27533)#28316
zeron-G wants to merge 1 commit intoopenclaw:mainfrom
zeron-G:fix/xai-reasoning-tag-provider

Conversation

@zeron-G
Copy link

@zeron-G zeron-G commented Feb 27, 2026

Summary

  • Problem: xai/grok-4-1-fast-non-reasoning outputs <think> tags as visible text to users.
  • Why it matters: Users see raw reasoning tags instead of clean responses.
  • What changed: Added xai to isReasoningTagProvider() so thinking tags are stripped for xAI models.
  • What did NOT change: No other providers affected; xAI reasoning models benefit from the same tag enforcement as Google/Minimax.

Closes #27533

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Integrations
  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

User-visible / Behavior Changes

xAI/grok model responses no longer show raw <think>...</think> tags.

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Repro + Verification

Environment

  • OS: macOS / Windows / Linux
  • Model/provider: xai/grok-4-1-fast-non-reasoning

Steps

  1. Set agent primary model to xai/grok-4-1-fast-non-reasoning
  2. Send any message
  3. Before: <think>... tags visible in response. After: tags stripped.

Evidence

  • Failing test/log before + passing after
✓ src/utils/utils-misc.test.ts (23 tests)
Tests  79 passed (across 3 test files)

Human Verification (required)

  • Verified scenarios: isReasoningTagProvider("xai") returns true; case-insensitive "XAI" also returns true.
  • Edge cases checked: existing providers (google, minimax, ollama) unaffected.
  • What you did not verify: Live xAI API call (unit-level only).

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No

Failure Recovery (if this breaks)

  • Revert single-line change in src/utils/provider-utils.ts.

Risks and Mitigations

None — additive change to an existing allowlist.

xai/grok models (including grok-4-1-fast-non-reasoning) emit <think>
tags in their text output. Without xai in isReasoningTagProvider(),
these tags leak to the user as visible text instead of being stripped.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 27, 2026

Greptile Summary

Adds xAI to the reasoning tag provider list to fix an issue where Grok models were displaying raw <think>...</think> tags as visible text to users. The change correctly integrates xAI with the existing tag stripping infrastructure that's already used by Google and Minimax providers.

Key changes:

  • Added normalized === "xai" to isReasoningTagProvider() in src/utils/provider-utils.ts
  • Added two test cases verifying both lowercase and case-insensitive matching

Implementation quality:

  • Follows the established pattern for provider checks (exact match comparison like Google)
  • Proper test coverage including case-insensitivity
  • Integrates cleanly with existing usage sites that set enforceFinalTag: true for reasoning providers

No issues found - clean, minimal, well-tested bug fix.

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • Single-line additive change to a provider allowlist with comprehensive test coverage. The implementation follows the exact pattern used by existing providers (Google), has no side effects on other code paths, and solves a well-defined bug. Tests verify both the core functionality and case-insensitivity.
  • No files require special attention

Last reviewed commit: c45d6e7

@openclaw-barnacle
Copy link

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle bot added the stale Marked as stale due to inactivity label Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: XS stale Marked as stale due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: When using the xai/grok-4-1-fast-non-reasoning model, the process of thinking is output

1 participant