Support OpenCode V2 in unsloth start by pascalandr · Pull Request #9275 · unslothai/unsloth · GitHub
Skip to content

Support OpenCode V2 in unsloth start - #9275

Merged
wasimysaid merged 9 commits into
unslothai:mainfrom
pascalandr:fix/opencode-v2-compat
Aug 20, 2026
Merged

Support OpenCode V2 in unsloth start#9275
wasimysaid merged 9 commits into
unslothai:mainfrom
pascalandr:fix/opencode-v2-compat

Conversation

@pascalandr

Copy link
Copy Markdown
Contributor

Summary

  • prefer the installed opencode2 binary while retaining the existing OpenCode V1 fallback
  • route V2 sessions through --standalone, avoid its unsupported root --model flag, and use V2-compatible auto/subagent configuration
  • exercise OpenCode V2 in the agent-guide CI install path

Why

OpenCode V2 installs side by side as opencode2 and changes its CLI/server contracts. The current integration only resolves opencode, injects a root --model flag that V2 rejects, and parses the V1 debug config response shape for subagents.

Reference: https://opencode.ai/v2/docs/migrate-v1

Testing

  • pytest unsloth_cli/tests/test_start.py -k opencode -q (71 passed)
  • ruff check unsloth_cli/commands/start.py unsloth_cli/tests/test_start.py
  • python -m compileall -q unsloth_cli/commands/start.py unsloth_cli/tests/test_start.py
  • bash -n .github/scripts/agent-guides-install.sh
  • real opencode2 beta smoke: generated config loaded through OPENCODE_CONFIG and OPENCODE_CONFIG_CONTENT; opencode2 models --standalone returned unsloth-studio/unsloth/v2-smoke

@chatgpt-codex-connector

Copy link
Copy Markdown

@danielhanchen

Copy link
Copy Markdown
Member

Confirmed main's unsloth_cli/commands/start.py still resolves only opencode and injects a root --model, so the V2 routing here fills a real gap. Could you keep .github/scripts/agent-guides-install.sh covering the stable opencode-ai install as well instead of replacing it with the beta package?

@pascalandr

pascalandr commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

Confirmed main's unsloth_cli/commands/start.py still resolves only opencode and injects a root --model, so the V2 routing here fills a real gap. Could you keep .github/scripts/agent-guides-install.sh covering the stable opencode-ai install as well instead of replacing it with the beta package?

@danielhanchen done.
Updated in 150324f and d49840c. The install script defaults to stable opencode-ai, and the connection matrix has a separate V2 cell. That V2 cell uses @opencode-ai/cli@beta only while @opencode-ai/cli@latest does not expose the opencode2 binary; it automatically switches to @latest when V2 is released as stable. This preserves V1 coverage without permanently pinning V2 to beta.

@pascalandr

Copy link
Copy Markdown
Contributor Author

Addressed the runtime review findings in 0fdf8da:

  • V2 no longer emits an ineffective provider-policy override; global/project policy remains authoritative and the CLI states that unsloth-studio must be allowed. An inherited inline allowlist is still extended at its own level so it does not block the local subagent.
  • V2 no longer forces experimental.subagent_depth to 1, preserving global/project depth.
  • Server-backed V2 commands (api, models, export, import, mini, run) now receive --standalone so the generated config reaches their server.
  • --no-launch now detects opencode2 in the official ~/.opencode/bin location without installing anything.

Validation: 73 targeted OpenCode tests, pre-commit hooks, Python compilation, workflow lint, and a real opencode2 models --standalone smoke.

@wasimysaid

Copy link
Copy Markdown
Collaborator

Thanks — I tested this at 0fdf8dad with a clean Studio/OpenCode V2 install and reproduced two issues:

  • with official V2 only in ~/.opencode/bin, normal launch works, but the exact --no-launch recipe fails with opencode2: command not found until PATH is changed;
  • the guide path builds opencode2 --standalone run ..., which the beta CLI rejects (it expects run --standalone).

Repros: https://github.com/wasimysaid/unsloth/actions/runs/32264293049 and https://github.com/wasimysaid/unsloth/actions/runs/32264440159. Could you re-check both command-building paths and add coverage? The private-server/models and provider-policy behavior worked for me.

@pascalandr

Copy link
Copy Markdown
Contributor Author

Fixed both paths in b38bf61. The V2 resolver now preserves the absolute ~/.opencode/bin/opencode2 path in --no-launch output, so the printed recipe no longer depends on PATH. Explicit V2 subcommands now place --standalone after the subcommand (opencode2 run --standalone ...), and the guide driver repositions the bare recipe's flag when it appends
un. Added focused CLI and guide-driver coverage; the OpenCode V2 tests and repository pre-commit hooks pass.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 19, 2026
@wasimysaid

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

@wasimysaid
wasimysaid merged commit 489fab4 into unslothai:main Aug 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants