Repository navigation
Stop unsloth start claude from opening with a model it cannot use - #10089
Conversation
|
Confirmed main only gates this on the codex path in unsloth_cli/commands/start.py, so |
…in the picker The helper rename in unslothai#10089 left unsloth_cli/tests/test_start.py calling the old Codex-specific names, so 71 tests failed with AttributeError and one still asserted that unsloth start claude accepts a non-GGUF model. - Migrate every caller to _preflight_agent_gguf / _attach_gguf_check / _fail_agent_needs_gguf with _CODEX_GGUF_AGENT, no behaviour change. - Turn the stale claude-accepts-non-GGUF assertion into a both-agents rejection test, with opencode as the control that must keep working. - Fold the new Claude cases into the CLI suite next to the Codex matrix, and replace the inspect.getsource wiring test with tests that drive the command: the preflight refuses before a server starts, the attach gate refuses before an evicting load, and a post-connect refusal tears down only a server this command started. - Treat claude as GGUF-only in the API examples agent picker too, so a safetensors model is no longer offered a command the CLI now rejects. - Restore the comment clause the rename dropped in _preflight_agent_gguf.
Follow-up to the Claude gate. Three things a differential simulation of the merge base against this branch turned up. _require_gguf_for_agent only failed open on a literal 404. A 401/403, any 5xx, a connection refused, a timeout or a non-JSON body all blocked the launch, and the last three surfaced as a raw traceback because only HTTPError was caught. Both callers wrap it in "except BaseException: _shutdown_auto_served()", so a transient blip tore down a server that had just finished loading a GGUF. The status route wraps its own llama.cpp and release probes in "except Exception: 500 Failed to get status", so a 500 is routinely raised with a healthy GGUF resident: it is not evidence about the model. Now only is_gguf present and false rejects. A body without the key is unknown too, which is what a Studio old enough to answer an unknown /api/* with 200 rather than 404 sends; it used to be read as a definite no and produced a wrong message about the user's model. A current server always sends the key explicitly, so nothing changes there. The API examples picker honoured a stored agent even when it could not run. agentPickedByUserRef is true whenever anything was persisted, so a preference saved before Claude Code was gated on GGUF short-circuited the check and kept offering a command the CLI now refuses. A restored pick that cannot run is now corrected and dropped; a pick made by hand in the same session still wins. The auto-pick guard was also wrong: an empty detected list means both "still fetching" and "nothing installed", so acting on it flipped the shown command between paints. It now waits for detection to answer, the same way the fetch effect does, and keeps its answer inside the agents the panel actually offers. Tests: 27 cases covering one gate branch each, and an exhaustive sweep of the picker's 320 reachable states asserting it settles, settles somewhere runnable and offered, and differs from the old rule only where the old answer could not run.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Reviewed this properly and pushed two commits to the branch. The change is right and worth landing. Summary of what I checked and what I changed. The issue is real
Leaving Worth noting the status quo was actively steering people into this. Before the PR, the API examples panel auto-picked with Before and after
What I pushed1. The existing test suite was broken. The helper renames never reached 2. Now only 3. The frontend picker. SimulationBlack-box differential: the same 422-cell matrix driven through the real Typer app with all HTTP, filesystem and subprocess calls stubbed, run against the merge base, the PR head and this branch in an isolated Merge base to this branch:
PR head to this branch: 408 of 422 unchanged, all 14 changes are the tolerance fix. Old installs. Both Platforms. Linux, macOS, Windows (via the suite's existing Hardware. No GPU coupling exists to break: Browsers. The shipped picker module was executed inside Chromium, Firefox and WebKit over all 320 reachable states: 320/320 in each, no page errors. WebKit is Safari's engine and Edge is Chromium, so those two are engine-level rather than product-level coverage; I am not claiming Safari.app or Edge.exe were run. For what it is worth the compile target is not close to being a problem either: Vite 8's Results
One thing I deliberately left alone: manually clicking Claude Code or Codex on a safetensors model still produces a command the CLI refuses. That was equally true for Codex before this PR, so it is not a regression this introduces, and fixing it properly wants a visible warning in the panel with a new i18n key across every locale. Worth a follow-up rather than widening this PR. The 41 failures in |
Opening comment-reduction pass over the added lines only: 144 comment lines down to 40, 72 percent, with every load-bearing fact kept. Deleted the ones that restate the code or the test name; collapsed the multi-line rationales to one line plus the citation that made them worth writing.
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Two holes in the picker, both from reading an uninitialised store as a fact. activeGgufVariant, activeNativePathToken and ggufContextLength all start null, so before /api/inference/status lands they are indistinguishable from a real non-GGUF model. In a browser, where agent detection never runs and detectedAgents stays empty for good, the first paint moved claude to opencode and the second could not move back: pickCompatibleAgent([], "opencode", true) correctly reports nothing to change. A GGUF session was therefore shown "unsloth start opencode" permanently. The same window let the restored- preference effect clear a saved claude or codex pick outright. isGguf is now boolean or null, keyed on params.checkpoint (the signal useExampleModelName already trusts), and both effects sit out the unresolved state. The helpers still take a plain boolean, so dropping either guard fails typecheck. A hand-made pick was also preserved for the whole session, which meant clicking claude under a GGUF model and then loading a safetensors one kept offering a command the CLI rejects. The session flag is replaced by the GGUF-ness the click was made under, so a manual pick survives exactly until the model changes beneath it, then gets revalidated like any other.
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
The panel names the model from the /v1/models catalog, not from params.checkpoint: useExampleModelName skips a checkpoint that is external or path-shaped and falls back to the resident catalog entry. While an external selection is active, use-chat-model-runtime deliberately stops applying local inference status (isExternalSelectionActive), so activeGgufVariant and friends freeze at whatever the last local model was. The catalog keeps polling, so if the resident model is replaced during that session the two drift apart with no path back to agreement, and the panel would keep offering claude or codex for a model that is no longer a GGUF, or discard a valid preference on the inverse transition. isGguf is now null for an external checkpoint as well as an unset one, using the same isExternalModelId predicate use-chat-model-runtime uses, so the two cannot disagree about what counts as external. Both effects already sit out null, so an unknown verdict re-steers nothing and clears nothing.
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 869af7d885
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!agentPickedByUserRef.current) return; | ||
| if (isGguf === null) return; | ||
| if (clickedUnderGgufRef.current === isGguf) return; |
There was a problem hiding this comment.
Reject incompatible manual agent selections
When the active model is safetensors or MLX, clicking the Claude or Codex chip sets clickedUnderGgufRef.current to false, so this equality guard immediately preserves the incompatible selection; the auto-pick effect also exits because the choice is marked manual. The panel then exposes an unsloth start claude/codex command that the newly added CLI gate rejects. Fresh evidence beyond the earlier model-change report is that the guard also fires when the user directly makes an incompatible selection without changing models; disable incompatible chips or validate the selected agent before preserving it.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not taking this one. Two things are being conflated: an incompatible selection that arrives by itself, and one the app inflicts on the user.
The equality guard exists so a pick made by hand survives until the model's GGUF-ness changes under it. A direct click on Claude with a safetensors model loaded is the first case, and preserving it is the intended behaviour, not a bypass: it is exactly what the panel did before this PR, so it is not a regression this PR introduces.
Both suggested remedies are worse than that. Disabling the chip leaves a dead control with no explanation of why, on a panel whose whole job is to show the command. Silently overriding an explicit click means the user presses Claude and the UI hands back something else, which is the one interaction people reliably read as a bug. Meanwhile the command the user copies is not a trap: unsloth start claude refuses up front with a message naming the model and pointing at the -GGUF sibling, which is the gate this PR adds.
The right fix is a visible warning next to the command, and that needs a new i18n key across every locale, so it is a scoped follow-up rather than something to bolt onto this PR.
The GGUF fields this panel read are populated by useChatModelRuntime, which only chat-page and hub-page mount, and local checkpoints are deliberately not persisted. Settings opens from any route, including a button on the API Monitor page that opens this exact panel, so off those two pages every field stayed empty, compatibility stayed unknown, and both effects bailed out: the panel kept offering the Claude command for a safetensors model. Ask /api/inference/status as well, polled on the catalog's cadence, and read is_gguf the way the CLI gate does: absent means the server did not report it, never "not GGUF". The store still wins when it has an answer, since it updates on the same paint as a model switch.
scripts/run_ruff_format.py wants this one on a single line. It is the only file this PR changes that the hook still adjusts.
The status poll and useExampleModelName's catalog poll run on separate timers, so a swap made from the CLI, another tab, or an auto-switching API request reaches one of them before the other. The verdict was keyed only on the chat store, which does not move for a swap made elsewhere, so for up to a poll the panel could pair a newly named safetensors model with the previous GGUF verdict and go on offering a Claude command the CLI refuses. Carry the resident identifier with the verdict and use it only while it still names the model the snippets name. Nothing named on either side is not a contradiction, and the ":quant" suffix useExampleModelName pins is not part of the identity. sameBaseModelId moves to agent-command.ts so both the existing caller and this rule share one definition and can be tested.
…ot guess when they disagree Two follow-on defects in the identity check added in the previous commit. /api/inference/status reports backend.active_model_name raw, while /v1/models passes the same value through public_model_id, so a locally loaded path arrives as "/models/foo" on one side and "foo" on the other and never matched. For a path-loaded model that discarded the server verdict permanently, which on routes that never mount the chat runtime left the gate dead again. The status side is now collapsed with publicModelId, the frontend port of that same backend rule. When the two polls do name different models, falling back to the chat store was wrong: a swap made from the CLI or another tab is exactly what the store does not see, so its verdict is about the model that left. That case is unknown now, and unknown gates nothing. Both readings live in one function, compatibilityFromSources, so the rule is in one place and under test rather than spread across four derived booleans.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Successive rounds left three explanations stacked above single statements. Same intent, 46 fewer lines. Comments only: comment_tools.py check reports code unchanged on all four files.
|
@codex review |
main gained isServedByLlamaCpp, which answers the question this branch derived inline and answers it better: loadedIsGguf is the backend's own verdict, and a context length is explicitly not evidence, since MLX reports one too. The store side now delegates to it and keeps only the tri-state around it, so an absent or external checkpoint still reads as unknown rather than as a definite no. The auto-pick effect main still carried is the one this branch replaces, so the branch version stands.
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aa585ca244
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const isGguf: boolean | null = compatibilityFromSources( | ||
| storeIsGguf, |
There was a problem hiding this comment.
Match the store verdict to the catalog model
In the Tauri panel, when a local selection changes from a non-GGUF model to a GGUF model, the store updates immediately while useExampleModelName can still name the previous resident model until its catalog request finishes. The stale status answer is correctly discarded by storeModelKey, but passing storeIsGguf here without checking activeCheckpoint against model makes isGguf true for the old non-GGUF model; with Claude detected, the auto-pick effect then briefly exposes a Claude command that the CLI rejects. Apply the same model-identity check to the store verdict or keep compatibility unknown until the catalog catches up.
Useful? React with 👍 / 👎.
…othai#16952) The note at the bottom of Settings > Agents said only Codex needs a GGUF model served by llama-server, and that other agents can also use transformer-backed models. `unsloth start claude` has refused non-GGUF local models since unslothai#10089, so anyone who followed the note with the Claude agent and a transformer model got a "needs a GGUF model served by llama-server" error when running the command. The note now names both agents that need a GGUF model. The same sentence is updated in every translated locale, since they all carried the old wording. The command line and its checks are unchanged. ### Before / after Settings > Agents with the default coding agent selected, merge base `1a4e758e9` (left) vs this PR `90ec1a76b` (right). The note under the subagent section now names both agents that need a GGUF model. 
If you have a normal safetensors model loaded and run
unsloth start claude, the command prints "Unsloth ready" and opens Claude Code. Every message then fails, because the messages endpoint only works with GGUF models. Claude Code treats the failure as a temporary server problem and keeps retrying, so you get a spinner and no answer. In testing it retried 8 times over 75 seconds and never gave up.unsloth start codexalready checks for this and refuses before it opens anything:This makes
claudedo the same. The three checks Codex already runs now take the agent name as an argument so both commands can share them. Codex's wording and behaviour are unchanged.opencodedoes not need this. It is set up as an OpenAI compatible provider and talks to/v1/chat/completions, which serves safetensors and MLX models fine. Only the Claude Code and Codex endpoints require GGUF.How to check: load a non GGUF model, run
unsloth start claude, and see it refuse instead of opening.