Repository navigation
fix(provider-grok): recheck Grok login once after a logged-out probe - #20358
Merged
juliusmarminge merged 7 commits intoOct 20, 2026
Merged
juliusmarminge merged 7 commits into
juliusmarminge merged 7 commits into
Conversation
Co-authored-by: Abdurahmon <89484240+abdurahmon27@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An expired access token makes `grok models` print "You are not authenticated." before the CLI refreshes the token in the same run, so the health check reported a signed-in user as logged out. Run `grok models` once more after the first process exits when it reports logged out, and use that verdict. A real logout stays unauthenticated. Builds on the approach in pingdotgg#14731. Fixes pingdotgg#14285 Co-authored-by: Abdurahmon <89484240+abdurahmon27@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
ApprovabilityVerdict: Needs Human Approval Macroscope's review found this PR requires human approval — This PR changes production Grok authentication detection, including when a provider transitions from unauthenticated to authenticated after a token refresh. Although the implementation is narrowly scoped and tested, authentication-related runtime changes require human review. You can add or adjust custom eligibility rules. Learn more. |
Contributor
Member
|
Taking over this one. I'll trim the tests to the useful coverage, rebuild the implementation against current main, run independent reviews, and verify it before pushing to this branch. |
… login recheck Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
When a Grok access token has expired but its refresh token is still valid,
grok modelsprints "You are not authenticated.", refreshes the token in the same process, and exits 0 without a login line. T3 Code read that first banner as the verdict, so a signed-in user saw "Grok is unauthenticated" and the picker hid Grok until providers were refreshed by hand. Fixes #14285.Change
checkGrokProviderStatusrunsgrok modelsonce more when the first clean run parses as logged out andXAI_API_KEYis unset. The second run starts only after the first process has exited, so it never contends with the CLI's own auth lock. Its verdict replaces the first one only when it carries a login line; a timeout, failed exit, or unparseable output keeps the first result, so a real logout still reports unauthenticated. Logged-in and API-key users run the command once as before.The probe body moved into a module-level
probeGrokModelshelper so it can run twice without duplicating the parsing or the failure log.Tests
One regression in
apps/server/src/provider/GrokProvider.test.ts: the fake CLI prints the logged-out banner on the firstmodelscall and the logged-in banner on the second, and the probe must reportready/authenticated. It fails onmain(expected 'error' to be 'ready') and passes here. The existing logged-out fixture repeats the same output on the recheck and still proves a real logout stays unauthenticated, so no further test was added.Verification
Headless Linux, Node 24.
checkGrokProviderStatusrun against a stubgrokbinary withXAI_API_KEYunset. "refresh" prints logged out on the firstmodelscall and logged in afterwards; "logged-out" always prints logged out. ACP initialize is not stubbed, hence thewarningstatus on the authenticated row.mainerror/unauthenticated, 1grok modelscallwarning/authenticated, 2 callserror/unauthenticated, 1 callerror/unauthenticated, 2 callsvp test run src/provider/GrokProvider.test.ts(apps/server): 34 passed.vp test runinpackages/provider-grok: 119 passed, 4 skipped.vp lint,vp fmt --check, andprovider-groktypecheck: clean.Independent read-only reviews by Claude Opus 5.5 and GPT-6-Sol found no blockers.
Takes over #20358 by @only21mil, whose diagnosis and regression test this keeps. Implementation: Claude Fable 5.1 through Claude Code in T3 Code.