Repository navigation
Fix opencode Unsloth provider selection - #6906
wasimysaid merged 13 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the opencode configuration and command-line execution to ensure that 'unsloth' is not disabled in the disabled_providers list and explicitly passes the --model flag. It also adds corresponding unit tests. Feedback is provided regarding a potential test failure on non-Windows platforms where single quotes wrapping the environment variable are not stripped, which causes a JSON decoding error.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8b2999759d
ℹ️ 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".
The session overlay wrote disabled_providers unconditionally and the inline OPENCODE_CONFIG_CONTENT set disabled_providers to an empty list. Since that inline layer outranks the user's global and project config and opencode replaces the array rather than merging it, every provider the user had disabled was silently re-enabled for the session. Only strip 'unsloth' from an existing disable list, and drop disabled_providers from the inline config. Also insert --model only on a bare launch: it is a global flag for the TUI, so placing it before a passthrough subcommand (serve/run) breaks arg parsing; a subcommand takes the model from the pinned config instead. Parse the printed OPENCODE_CONFIG_CONTENT with shlex.split in the test so it round-trips under POSIX shell quoting.
|
Pushed a small revision (19e16a4) on top of your branch:
Verified with the full |
…h-provider-selection # Conflicts: # unsloth_cli/commands/start.py
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 15ddbf7051
ℹ️ 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".
A fresh OPENCODE_CONFIG overlay omits disabled_providers, and opencode replaces that array across config layers only when a higher layer sets the key, so a user's global disabled_providers of ['unsloth', ...] survived the merge and left the session provider disabled even though the overlay defines provider.unsloth and pins the model. Consult the user's global opencode config (XDG_CONFIG_HOME/opencode, or %APPDATA%/opencode on Windows) when the overlay has no list of its own, and when the effective list disables unsloth write it back to the overlay minus unsloth. The provider loads while the user's other disabled providers stay disabled. Best-effort read: a missing or unparseable global config is a no-op.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2d60f55439
ℹ️ 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".
…flag for TUI flags Re-enabling a disabled unsloth provider now rides in the inline OPENCODE_CONFIG_CONTENT layer instead of the session overlay. The overlay sits below a project opencode.json, which could re-disable the provider; the inline layer outranks both global and project configs and is recomputed each run, so no-launch reruns never reuse a stale generated list. The effective disabled list is read from the project config if the repo sets one, else the global config, across config.json/opencode.json/opencode.jsonc (JSONC tolerated), and written back minus unsloth only when unsloth is disabled. Also keep the pinned --model when the opencode passthrough starts with a top-level TUI flag such as --dir or --continue; only a real subcommand (serve/run/...) takes the model from config, so a leading '-' now still gets --model injected.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f43e072ae4
ℹ️ 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".
opencode finds a project config by searching ancestor directories, not just the cwd. Walk from the cwd up to the filesystem root and use the nearest directory that sets disabled_providers, so running unsloth start opencode from a subdirectory of a repo whose root config disables unsloth still gets the inline override.
|
@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: 714cc30d57
ℹ️ 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".
| for name in ("config.json", "opencode.json", "opencode.jsonc"): | ||
| data = _load_opencode_config(directory / name) |
There was a problem hiding this comment.
Scan
.opencode configs for disabled providers
When a project keeps its OpenCode settings in the supported .opencode/opencode.json or .opencode/opencode.jsonc directory config, this helper never reads it, because it only checks files directly in each walked directory. In that setup, .opencode/opencode.json with disabled_providers: ["unsloth"] is still loaded by OpenCode and disables the provider, but the wrapper thinks nothing needs to be overridden and omits the inline disabled_providers fix.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid: opencode also reads .opencode/ config directories, which the scan does not cover. See the summary comment below.
…el pin Injecting --model whenever the passthrough started with a flag could place it before a subcommand (e.g. opencode --print-logs serve), which opencode can misparse. --model is unnecessary for any passthrough because the inline OPENCODE_CONFIG_CONTENT pins the model in the highest-priority layer, so the session model is forced without the flag. Restrict --model to the bare launch and pass any other invocation through untouched.
|
On the disabled_providers handling: the recent review items (global config dirs, ancestor project walk, A simpler and fully robust alternative sidesteps all of it: register the session provider under an id the user's The current inline-layer override is in place and covers the common global and project cases, so this PR is not blocked. But given the growing edge-case list, switching to a session-unique provider id is likely the cleaner long-term fix. Happy to help wire that up if you want to go that route. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f06c808575
ℹ️ 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".
Selecting the Unsloth model reliably required the wrapper to re-enable a
user-disabled unsloth provider, which meant reconstructing OpenCode's full
disabled_providers resolution (global, OPENCODE_CONFIG overlay, project config
discovered via --dir or an ancestor walk, .opencode directories,
OPENCODE_CONFIG_DIR, config.json/opencode.json/opencode.jsonc precedence, and
{env:} variable substitution) and overriding it in the inline layer. That is
unbounded and cannot be kept correct.
Register the session provider under a dedicated id (unsloth-studio) instead. A
user's disabled_providers list would never target it, so the session model is
always selectable and the overlay no longer reads or writes disabled_providers
at all: the user's own disables, in whatever config layer, are left exactly as
they are. This removes the JSONC parser, the config-directory scan, and the
ancestor/global resolution helpers, and the tests that exercised them.
|
Switched the opencode integration to register the session provider under a dedicated id ( Why: making the model selectable when the user disabled the Registering under an id the user's disable list would never target sidesteps all of it: the session model is always selectable, and the overlay no longer touches |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9b81e22235
ℹ️ 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".
| # user's disable list would never target, so the model is always selectable | ||
| # without the wrapper having to reconstruct (and override) OpenCode's full, | ||
| # multi-layer disabled_providers resolution. | ||
| _OPENCODE_PROVIDER = "unsloth-studio" |
There was a problem hiding this comment.
Account for enabled_providers allowlists
OpenCode's config docs say enabled_providers is an allowlist where only the listed provider IDs are enabled, and merged lower-priority config keys are preserved. With this new provider id, a user who already had enabled_providers: ["unsloth"] (which matched the previous session provider) will now keep that allowlist while the wrapper writes and pins unsloth-studio/...; OpenCode then filters out the session provider before the pinned model can load, so unsloth start opencode still falls back/fails for those configs. The fix needs to handle enabled_providers in the overlay as well, or keep using an ID that existing allowlists include.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 1e6c5de. Confirmed against opencode source that enabled_providers/disabled_providers filter config-defined providers too, a model pin does not bypass the gate, and both arrays are replaced (not merged) across layers. The inline OPENCODE_CONFIG_CONTENT overlay now sets enabled_providers to just the session provider and clears disabled_providers, which (being the highest-priority layer that replaces these arrays) guarantees the Studio model survives any user allowlist or denylist. It is session-only and never reads or edits the user's config files, so their persistent opencode config is untouched; only this session is scoped to the Studio provider.
opencode filters every provider, including a config-defined custom one, through its enabled_providers allowlist and disabled_providers denylist, and pinning the model does not bypass that gate (a filtered provider resolves to a not-found error). The provider arrays are also replaced, not merged, across config layers. So a user with an enabled_providers allowlist that omits the session provider would still have the Studio model filtered out. Set enabled_providers to just the session provider and clear disabled_providers in the inline OPENCODE_CONFIG_CONTENT overlay (the highest-priority layer, which replaces these arrays). This guarantees the Studio model loads regardless of the user's provider filters, without reading or reconstructing their multi-layer config. It is session-only: the overlay lives in the env for this launch and never touches the user's config files, so their normal opencode is unchanged and only this session is limited to the Studio provider. Also drop the redundant --model on --no-launch so the printed command stays append-safe for drivers that append a subcommand (the inline pin forces the model), and parse both POSIX and PowerShell no-launch output in the opencode tests so they are not shell-specific.
|
@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: 1e6c5dec0b
ℹ️ 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".
| inline_config: dict = { | ||
| "model": opencode_model, | ||
| "enabled_providers": [_OPENCODE_PROVIDER], | ||
| "disabled_providers": [], | ||
| } |
There was a problem hiding this comment.
Pin small_model under the provider allowlist
When a user or project already has small_model set to another provider (for example openai/gpt-4o-mini), this inline overlay now allowlists only _OPENCODE_PROVIDER but leaves that separate model setting intact. OpenCode documents small_model as a separate model used for lightweight tasks and enabled_providers as an allowlist, so those tasks can resolve a filtered provider and error even though the main model is pinned to Studio; include "small_model": opencode_model in the same overlay (or avoid the allowlist) so all model uses stay on the enabled provider.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 60ec64b: the inline overlay now also pins small_model to the session model. Since the session serves one model and is scoped to the Studio provider, that is the only valid target, so opencode's lightweight tasks stay on the enabled provider instead of resolving a filtered one. Still session-only; the user's config is untouched.
The session allowlists only the Studio provider, but opencode's separate small_model (used for lightweight tasks) could still point at another provider from the user or project config; under the allowlist that provider is filtered, so the lightweight task would resolve a not-found error mid-session even with the main model pinned. Pin small_model to the session model in the same inline overlay so every model use stays on the enabled provider. The session serves one model, so it is the only valid target, and this stays session-only like the rest of the overlay.
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. 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". |
Summary
--model unsloth/<model>argument.unslothand for the no-launch command/env output.Root Cause
unsloth start opencodewrites a session provider namedunsloth, but opencode merges user config first. If the user-level config containsdisabled_providers = ["unsloth"], the session provider exists but remains disabled, so the TUI can fall back to another configured provider/model such as Ollama Cloud.Validation
python -m py_compile unsloth_cli/commands/start.py unsloth_cli/tests/test_start.pygit diff --checktest_write_opencode_config_fresh,test_write_opencode_config_preserves_and_idempotent,test_connect_opencode_no_launchdisabled_providers: []enables theunslothprovider.