Repository navigation
Conversation
`strix auth login mistral` signs in with Mistral's OIDC issuer (Ory Hydra, public CLI client, PKCE) and `STRIX_LLM=lechat/<model>` runs inference on the subscription through api.mistral.ai's chat completions, with no API key. The API authenticates the ID token, not the access token, and needs the caller's organization and workspace in x-external-* headers; the tenant is discovered once at sign-in and the record expires with the ID token. Reasoning models answer with thinking/text content chunks, which the Mistral chat model reshapes into the text and reasoning_content the SDK reads, streamed or not. A Subscription registry (subscriptions.py) replaces the codex-only prefix checks at every call site; mistral/ stays LiteLLM's API-key route.
[Medium impact] The PR adds a Mistral subscription path to scan setup and model calls. Lock shared credential changes before merging so signing out of one provider cannot break another provider's scans. Findings
Fix with agent prompt### Issue 1
strix/config/mistral.py:104-109
`logout()` rewrites the shared store without taking the refresh lock. If Mistral logout reads the store just before a running ChatGPT scan saves a rotated refresh token, logout writes the old ChatGPT token back. The next refresh fails because that token has already been spent, forcing the user to sign in again.
Use one shared lock for every provider's store changes, including login and logout, not just refresh.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryAdds Mistral subscription sign-in and the
Acknowledged by
Reviews (1) · Last reviewed commit: "feat(auth): run on a Mistral subscriptio..." · Reviewed by Greptile |
| data = _read_store() | ||
| if PROVIDER not in data: | ||
| return | ||
| del data[PROVIDER] | ||
| if data: | ||
| _write_store(data) |
There was a problem hiding this comment.
Logout overwrites refreshed credentials
logout() rewrites the shared store without taking the refresh lock. If Mistral logout reads the store just before a running ChatGPT scan saves a rotated refresh token, logout writes the old ChatGPT token back. The next refresh fails because that token has already been spent, forcing the user to sign in again.
Use one shared lock for every provider's store changes, including login and logout, not just refresh.
Prompt To Fix With AI
This is a comment left during a code review.
Path: strix/config/mistral.py
Line: 104-109
Comment:
**Logout overwrites refreshed credentials**
`logout()` rewrites the shared store without taking the refresh lock. If Mistral logout reads the store just before a running ChatGPT scan saves a rotated refresh token, logout writes the old ChatGPT token back. The next refresh fails because that token has already been spent, forcing the user to sign in again.
Use one shared lock for every provider's store changes, including login and logout, not just refresh.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
Valid, fixed in 2b6ebed. The store, its path, and its lock moved into strix/config/subscription_store.py. save_record, logout, and token refresh for both providers now hold the same locked() (thread lock + flock), so a Mistral logout or login blocks until an in-flight ChatGPT refresh has saved its new token. Regression test: test_logout_waits_for_a_chatgpt_refresh_and_keeps_its_rotated_token.
ChatGPT and Mistral records share subscription-auth.json, but only token refresh took a lock, and each provider had its own copy of it. A logout or login that read the file before a peer saved a rotated refresh token wrote the spent token back, forcing a fresh sign-in. The store, its path and a single locked() guard (thread lock + flock) move to subscription_store.py. save_record, logout and refresh for both providers now hold it.
Summary
Adds a second model subscription next to ChatGPT. You sign in to Mistral once, and you can then run scans on
lechat/<model>with no API key.mistral/<model>still goes through LiteLLM withLLM_API_KEY, as it does today.Changes
strix/config/mistral.py(new): OIDC sign-in againstauth.mistral.ai(Ory Hydra, public client, PKCE, loopback callback on127.0.0.1:8766). Also handles refresh-token rotation under a file lock, shares the token store~/.strix/subscription-auth.json, and provides anAsyncOpenAIclient that sets the auth headers on every request.api.mistral.aiauthenticates the ID token. The access token (opaqueory_at_…) gets401 Invalid API Key.x-external-organization-idandx-external-workspace-id. The tenant comes fromGET /v1/users/me/workspacesonce at sign-in and is carried across refreshes.mistral-large-latestreturnscontentas a list ofthinkingandtextchunks. The Agents SDK expects a string and fails withResponseOutputText … Input should be a valid string._MistralChatModelturns text chunks intocontentand thinking chunks intoreasoning_content, in both streamed and non-streamed responses.strix/config/subscriptions.py(new): a smallSubscriptionregistry (ChatGPT, Mistral). It replaces thechatgpt/prefix checks that were hardcoded in the CLI, environment checks, scan setup, report state and runner.strix auth login|status|logoutnow loops over the registry.lechat/xlooks up LiteLLM's model info undermistral/xand never sends the rawlechat/name to LiteLLM.LLM_DISABLE_STREAMINGapplies tolechat/models.Reviewer notes
829da7e7-…is the public client that Mistral's own CLI (Mistral Vibe) uses. Mistral doesn't publish a client for third-party tools that I know of. If you'd rather not ship it, this PR can wait until Mistral gives Strix its own client.lechat/:mistral/is already LiteLLM's API-key route, and reusing it would break existing configs.VIBE_CLI_OIDC_WORKSPACE_ID). I can add one if you want it.thinking/textcontent shape. This PR fixes it only forlechat/models. Theopenai/<model>+LLM_API_BASE=https://api.mistral.ai/v1route in [BUG] ResponseOutputText mishandles thinking text in blocks #1357 still goes through LiteLLM and isn't changed here.Testing
tests/test_mistral_auth.py: sign-in exchange, tenant discovery, missingid_tokenand workspace, refresh and rotation races, request headers, and the client hook on realhttpxrequests.tests/test_models.py: thinking content, streamed and non-streamed.tests/test_auth_cli.py,tests/test_context_budget.py,tests/test_disable_streaming.py.ruff check,ruff format --checkandmypyare clean.make check-allstill fails at pyright because of errors already onmain.main(mostly_start_child_runner() missing … 'skills'). Nothing in this PR causes them.auth status, a forced refresh (the refresh token rotated and the account was kept), and listing models.lechat/mistral-large-latest: it found the injection, and all 36 LLM requests returned 200 fromapi.mistral.ai.LLM_DISABLE_STREAMING=1, after expiring the stored token: it refreshed, then made 9 non-streamed requests, all 200.