Research OpenCode CLI installation and local-endpoint setup #7

Closed
opened 2026-08-24 16:13:20 +00:00 by haylan · 1 comment
Owner

Part of #1

Question

How is OpenCode CLI (sst/opencode) installed, and how is it correctly configured to point at this stack's local llama.cpp server instead of a hosted provider? Specifically: install method (npm/curl script/binary), config file location/format, which provider type to declare (OpenAI-compatible custom endpoint vs. a dedicated "local"/"openai-compatible" provider block), the exact base_url/model/api_key fields needed to hit llama.cpp's /v1/chat/completions on http://localhost:8080, and whether OpenCode's tool-calling/agentic loop has any documented compatibility requirements or known issues with self-hosted OpenAI-compatible servers (especially llama.cpp) that would matter for Qwen3.8-27B specifically. Compare against how Kimi CLI's config.toml was already set up (see #6) so the docs stay consistent.

Part of #1 ## Question How is OpenCode CLI (sst/opencode) installed, and how is it correctly configured to point at this stack's local llama.cpp server instead of a hosted provider? Specifically: install method (npm/curl script/binary), config file location/format, which provider type to declare (OpenAI-compatible custom endpoint vs. a dedicated "local"/"openai-compatible" provider block), the exact base_url/model/api_key fields needed to hit llama.cpp's /v1/chat/completions on http://localhost:8080, and whether OpenCode's tool-calling/agentic loop has any documented compatibility requirements or known issues with self-hosted OpenAI-compatible servers (especially llama.cpp) that would matter for Qwen3.8-27B specifically. Compare against how Kimi CLI's config.toml was already set up (see #6) so the docs stay consistent.
haylan added the wayfinder:research label 2026-08-24 16:13:20 +00:00
haylan self-assigned this 2026-08-24 16:13:21 +00:00
Author
Owner

Resolved. Full findings: docs/research/opencode-cli-setup.md on branch research/opencode-cli-setup.

Project confirmed: sst/opencode moved orgs — now github.com/anomalyco/opencode (docs at opencode.ai/docs). Not to be confused with the unrelated opencode-ai/opencode (Go TUI project).

Install: curl -fsSL https://opencode.ai/install | bash (or npm i -g opencode-ai@latest, or brew install anomalyco/tap/opencode).

Config: JSON/JSONC at ~/.config/opencode/opencode.json (global) or opencode.json in project root. Local provider block:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "llamacpp": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "llama.cpp (local)",
      "options": { "baseURL": "http://localhost:8080/v1", "apiKey": "sk-local-not-checked" },
      "models": { "qwen3.8-27b": { "name": "Qwen3.8-27B", "limit": { "context": 131072, "output": 8192 } } }
    }
  }
}

Select with llamacpp/qwen3.8-27b.

Caveats (both documented, primary-source):

  • OpenCode issue #1890: sends tools/Jinja scaffolding unconditionally — llama.cpp needs --jinja or it 500s; some model templates crash llama.cpp's Jinja renderer even with --jinja on.
  • OpenCode issue #20669 (closed, not planned by maintainers): local-backend tool-call brittleness — bash tool throws if a model omits the optional description field; some local backends return finish_reason: tool_calls with an empty tool_calls: [], causing loop/hang.
  • Qwen3.8-27B specifically: this repo's own docs/research/qwen3.8-27b-tool-calling.md independently found open llama.cpp upstream tool-call parser bugs for the Qwen3.5/Qwen3.8 lineage — expect unreliable tool-calling regardless of OpenCode config correctness.
  • Thinking-mode (<think> tags) handling in OpenCode against llama.cpp is undocumented — flagged low-confidence/open question, recommend empirical testing once tool-calling is unblocked.

Full citations and confidence levels for every claim are in the doc.

**Resolved.** Full findings: `docs/research/opencode-cli-setup.md` on branch `research/opencode-cli-setup`. **Project confirmed**: sst/opencode moved orgs — now **github.com/anomalyco/opencode** (docs at opencode.ai/docs). Not to be confused with the unrelated opencode-ai/opencode (Go TUI project). **Install**: `curl -fsSL https://opencode.ai/install | bash` (or `npm i -g opencode-ai@latest`, or `brew install anomalyco/tap/opencode`). **Config**: JSON/JSONC at `~/.config/opencode/opencode.json` (global) or `opencode.json` in project root. Local provider block: ```json { "$schema": "https://opencode.ai/config.json", "provider": { "llamacpp": { "npm": "@ai-sdk/openai-compatible", "name": "llama.cpp (local)", "options": { "baseURL": "http://localhost:8080/v1", "apiKey": "sk-local-not-checked" }, "models": { "qwen3.8-27b": { "name": "Qwen3.8-27B", "limit": { "context": 131072, "output": 8192 } } } } } } ``` Select with `llamacpp/qwen3.8-27b`. **Caveats (both documented, primary-source)**: - OpenCode issue #1890: sends `tools`/Jinja scaffolding unconditionally — llama.cpp needs `--jinja` or it 500s; some model templates crash llama.cpp's Jinja renderer even with `--jinja` on. - OpenCode issue #20669 (closed, not planned by maintainers): local-backend tool-call brittleness — bash tool throws if a model omits the optional `description` field; some local backends return `finish_reason: tool_calls` with an empty `tool_calls: []`, causing loop/hang. - Qwen3.8-27B specifically: this repo's own `docs/research/qwen3.8-27b-tool-calling.md` independently found open llama.cpp upstream tool-call parser bugs for the Qwen3.5/Qwen3.8 lineage — expect unreliable tool-calling regardless of OpenCode config correctness. - Thinking-mode (`<think>` tags) handling in OpenCode against llama.cpp is undocumented — flagged low-confidence/open question, recommend empirical testing once tool-calling is unblocked. Full citations and confidence levels for every claim are in the doc.
Sign in to join this conversation.