You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 768e0f6
Browse filesBrowse the repository at this point in the historyBrowse files
fix: _isGrokXAI false-positive substring match breaks token usage for domains containing 'x.ai'
Fixes#1483
The _isGrokXAI() method used urlHost.includes('x.ai') which matches any
domain containing 'x.ai' as a substring (e.g. box.ai, fox.ai, max.ai).
This false-positive causes stream_options:{include_usage:true} to be
omitted, so the API never returns usage data and the token bar shows 0.
Fix: Use exact host match (api.x.ai) or subdomain match (*.x.ai) instead
of substring includes.
Added tests for false-positive scenarios and valid x.ai domain detection.
AI-assisted: developed with Zoo Code/GLM-5.2, reviewed and verified by the contributor.
Fix `_isGrokXAI()` false-positive substring match that broke token usage for OpenAI-compatible providers whose domain contains "x.ai" as a substring (e.g. box.ai, fox.ai, max.ai).
6
+
7
+
The `_isGrokXAI()` method in `src/api/providers/openai.ts` used `urlHost.includes("x.ai")` which is a substring match. Any domain containing "x.ai" anywhere in its host (e.g. `box.ai`, `fox.ai`, `max.ai`) was falsely identified as a Grok/xAI endpoint. This caused `stream_options: { include_usage: true }` to be omitted from API requests in both `createMessage()` and `handleO3FamilyMessage()`, so the API never returned usage data and the token bar showed 0 — a silent failure with no error message.
8
+
9
+
Fixed by using exact host match (`api.x.ai`) or subdomain suffix check (`.x.ai`) instead of substring `includes()`.
0 commit comments