Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

unsloth start opencode: never pass --model on a bare launch; OpenCode 2 rejects it (#13783)

Yogesh Seenichamy8060a5ee8a0f
diff --git a/unsloth_cli/commands/start.py b/unsloth_cli/commands/start.py
index b80bda0458b..c703a74498c 100644
--- a/unsloth_cli/commands/start.py
+++ b/unsloth_cli/commands/start.py
@@ -6980,7 +6980,7 @@ def opencode(
as_subagent = as_subagent or auto_route
_check_app_flags(app, ctx.args, as_subagent)
command_name, opencode_v2 = _opencode_command()
- install_hint = _npm_install_hint("@opencode-ai/cli@beta" if opencode_v2 else "opencode-ai")
+ install_hint = _npm_install_hint("@opencode/cli" if opencode_v2 else "opencode-ai")
_require_agent_for_launch(command_name, install_hint, launch and not app)
server_options = ServerOptions(
enable_tools = enable_tools,
@@ -7087,7 +7087,7 @@ def opencode(
)
return
opencode_model = f"{_OPENCODE_PROVIDER}/{entry['id']}"
- # The inline OPENCODE_CONFIG_CONTENT below pins the model in the highest-priority layer, so the session model is forced without a --model flag. Only add --model for an interactive bare launch, as a convenience so the TUI opens on our model: it is omitted for passthrough, where inserting it before a subcommand can be misparsed, and for --no-launch, where the printed command is consumed by drivers that append a subcommand such as `run <prompt>` and a leading --model would land before it. Those paths rely on the inline pin instead.
+ # The inline OPENCODE_CONFIG_CONTENT pin below selects the model, so no path passes --model: it misparses before a passthrough subcommand, lands before the `run <prompt>` drivers append to a --no-launch recipe, and OpenCode 2 rejects it on the root command, which a V2 build whose --version probe fails would get (#13747).
native_auto = False
route_native_auto = yolo and (opencode_v2 or _opencode_supports_native_auto(command_name))
if ctx.args:
@@ -7099,9 +7099,7 @@ def opencode(
)
command = [command_name, *opencode_args]
elif launch:
- opencode_args = [] if opencode_v2 else ["--model", opencode_model]
- if opencode_v2:
- opencode_args = _opencode_v2_standalone_args(opencode_args)
+ opencode_args = _opencode_v2_standalone_args([]) if opencode_v2 else []
opencode_args, native_auto = _opencode_native_auto_args(
opencode_args,
route_native_auto,
diff --git a/unsloth_cli/tests/test_start.py b/unsloth_cli/tests/test_start.py
index 033cffcfcb8..af2a1611f30 100644
--- a/unsloth_cli/tests/test_start.py
+++ b/unsloth_cli/tests/test_start.py
@@ -6652,6 +6652,30 @@ def test_connect_opencode_v2_named_opencode_launches_without_model_flag(fake_stu
assert launched == [["opencode", "--standalone", "--auto"]]
+def test_opencode_bare_launch_never_passes_root_model_flag(fake_studio, monkeypatch):
+ # A V2 build whose --version probe fails gets the V1 verdict and rejects --model (#13747).
+ monkeypatch.setattr(start.shutil, "which", lambda _: "/usr/local/bin/opencode")
+ captured = _capture_launch(monkeypatch, ["opencode"])
+
+ assert captured["command"][1:] == []
+ assert "--model" not in captured["command"]
+ inline = json.loads(captured["env"]["OPENCODE_CONFIG_CONTENT"])
+ assert inline["model"] == f"{start._OPENCODE_PROVIDER}/{MODEL['id']}"
+
+
+def test_opencode_v2_install_hint_names_the_opencode_cli_package(fake_studio, monkeypatch):
+ # OpenCode 2 ships on npm as @opencode/cli; @opencode-ai/cli only carries 0.0.0-beta builds.
+ monkeypatch.setattr(start, "_opencode_command", lambda *_: ("opencode2", True))
+ hints = []
+ monkeypatch.setattr(start, "_run", lambda *a, **k: hints.append(k["install_hint"]))
+
+ result = CliRunner().invoke(start.start_app, ["opencode"])
+
+ assert result.exit_code == 0, result.output
+ assert len(hints) == 1 and "@opencode/cli" in hints[0], hints
+ assert "@opencode-ai/cli" not in hints[0]
+
+
def test_connect_opencode_v2_no_launch_uses_resolved_off_path_binary(
fake_studio, monkeypatch, tmp_path
):
@@ -8086,11 +8110,8 @@ def test_yolo_opencode_bare_launch_uses_native_auto(fake_studio, monkeypatch):
monkeypatch.setattr(start.shutil, "which", lambda _: "/usr/local/bin/opencode")
monkeypatch.setattr(start, "_opencode_supports_native_auto", lambda *_: True)
captured = _capture_launch(monkeypatch, ["opencode", "--yolo"])
- assert captured["command"][1:] == [
- "--model",
- f"{start._OPENCODE_PROVIDER}/{MODEL['id']}",
- "--auto",
- ]
+ assert captured["command"][1:] == ["--auto"]
+ assert "--model" not in captured["command"]
assert "permission" not in json.loads(captured["env"]["OPENCODE_CONFIG_CONTENT"])
@@ -9039,7 +9060,7 @@ def test_persist_bare_opencode_launch_has_no_resume_token(fake_studio, monkeypat
monkeypatch.setattr(start.shutil, "which", lambda _: "/usr/local/bin/opencode")
captured = _capture_launch(monkeypatch, ["opencode", "--persist"])
assert "--continue" not in captured["command"]
- assert captured["command"][1:] == ["--model", f"{start._OPENCODE_PROVIDER}/{MODEL['id']}"]
+ assert captured["command"][1:] == []
def test_persist_bare_claude_launch_has_no_resume_token(fake_studio, monkeypatch):