Skip to content

HarnessRouter Community Edition: the self-hosted, Apache-2.0 edition of the unified interface for agent harnesses. Run Codex, Claude Code, Hermes, PI, DSH, and more through one API, with sessions, streaming, files, cancellation, and failure handling. Implements the Unified Harness Protocol (UHP), an open standard. Your keys, your infrastructure.

feat: opencode serves the full multi-family model set

richard-epsilla0300d8d80916
diff --git a/gateway/app.py b/gateway/app.py
index 830964ca..3539dea2 100644
--- a/gateway/app.py
+++ b/gateway/app.py
@@ -4449,12 +4449,21 @@ _MODEL_CATALOG: dict[str, dict] = {
"gemini-3.6-flash", "kimi-k3", "kimi-k2.7-code",
"qwen3.7-max", "qwen3.8-max",
"mistral-medium-3.5", "step-3.7-flash"]},
- # OPENCODE IS SEEDED, NOT EARNED. Per the bar at the top of this table a model belongs here
- # only after a real turn on this backend completed against the live provider and was checked
- # for substitution. None of that has happened yet: this single entry exists so the base is
- # routable at all (without it every request falls back and the fallback IS the trap this
- # comment block describes). Probe it, then keep it and add siblings — or remove the base.
- "opencode": {"default": "gpt-5.4", "models": ["gpt-5.4"]},
+ # opencode reaches every model the same way pi does: one OpenAI-compatible (or Messages, or
+ # Responses) client pointed at our relay, with the package chosen per turn from the model
+ # family (see _opencode_config, which mirrors _pi_models_json). The serving paths are
+ # therefore pi's, and pi's rows earned them — so the catalogue is pi's set.
+ # STILL UNPROBED ON THIS BACKEND: inheriting a serving path is not the same as a completed
+ # turn, which is what the bar at the top of this table asks for. Probe before relying on any
+ # single row here.
+ "opencode": {"default": "gpt-5.4",
+ "models": ["gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna", "gpt-5.5",
+ "gpt-5.4", "gpt-5.4-mini", "gpt-5.2", "gpt-5.3-codex",
+ "claude-opus-5", "claude-fable-5", "claude-opus-4.8", "claude-sonnet-5",
+ "claude-opus-4.7", "claude-sonnet-4.6", "claude-haiku-4.5",
+ "gemini-3.6-flash", "deepseek-v4-pro", "deepseek-v4-flash", "kimi-k3",
+ "kimi-k2.7-code", "qwen3.7-max", "qwen3.8-max",
+ "mistral-medium-3.5", "step-3.7-flash"]},
"pi": {"default": "gpt-5.4",
"models": ["gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna", "gpt-5.5",
"gpt-5.4", "gpt-5.4-mini", "gpt-5.2", "gpt-5.3-codex",
diff --git a/runner/server.py b/runner/server.py
index e76420f1..648a33c5 100644
--- a/runner/server.py
+++ b/runner/server.py
@@ -2148,13 +2148,25 @@ def _opencode_mcp(servers: list[dict] | None) -> dict:
def _opencode_config(auth: Auth, model: str, cwd: str, mcp_servers: list[dict] | None,
- skills_dir: str | None, tools_disabled: list[str] | None = None) -> str:
+ skills_dir: str | None, tools_disabled: list[str] | None = None,
+ pr: str = "") -> str:
"""Write <cwd>/opencode.json and return the provider-qualified model id for --model."""
if not auth.base_url:
raise HTTPException(400, "opencode needs a base_url (none configured)")
- # /v1/responses endpoints need the openai provider package; everything else is the
- # openai-compatible one. Same split the docs draw, same model heuristic the tree already uses.
- npm = "@ai-sdk/openai" if _HERMES_RESPONSES_API_MODEL.search(model or "") else "@ai-sdk/openai-compatible"
+ # Which ai-sdk package serves this turn. A turn runs exactly ONE model, so this is decided per
+ # turn at provider level rather than per model entry — opencode resolves
+ # `model.provider?.npm ?? provider.npm ?? "@ai-sdk/openai-compatible"`, so the provider-level
+ # value is what a single-model config needs.
+ #
+ # The split MIRRORS _pi_models_json, because both reach the same relays over the same wire
+ # formats: a claude model on an anthropic-native connection speaks Messages, not
+ # chat/completions, and sending it to the openai-compatible package fails at the first call.
+ if pr == "anthropic" or (pr == "tokenrouter" and _PI_CLAUDE_MODEL.search(model or "")):
+ npm = "@ai-sdk/anthropic"
+ elif pr == "azure" or _HERMES_RESPONSES_API_MODEL.search(model or ""):
+ npm = "@ai-sdk/openai" # /v1/responses
+ else:
+ npm = "@ai-sdk/openai-compatible" # /v1/chat/completions
cfg: dict = {
"$schema": "https://opencode.ai/config.json",
"provider": {
@@ -2187,7 +2199,7 @@ def _build_opencode(provider: str, auth: Auth, model: str, prompt: str, cwd: str
raise HTTPException(400, f"unknown opencode provider '{pr}' (one of {sorted(OPENCODE_PROVIDERS)})")
if auth.api_key:
env[_OPENCODE_KEY_ENV] = auth.api_key
- qualified = _opencode_config(auth, model, cwd, mcp_servers, skills_dir, tools_disabled)
+ qualified = _opencode_config(auth, model, cwd, mcp_servers, skills_dir, tools_disabled, pr)
cmd = ["opencode", "run", "--format", "json", "--model", qualified,
# The sandbox is the trust boundary, so permissions are granted up front: nobody is
# attached to answer a prompt. Same rationale as pi --approve and claude
diff --git a/runner/tests/test_opencode_normalize.py b/runner/tests/test_opencode_normalize.py
index 90244a18..6b27b87a 100644
--- a/runner/tests/test_opencode_normalize.py
+++ b/runner/tests/test_opencode_normalize.py
@@ -203,3 +203,33 @@ def test_opencode_instructions_go_to_agents_md_not_claude_md():
from server import _agent_doc_path # noqa: PLC0415
assert _agent_doc_path("/ws", "opencode").name == "AGENTS.md"
assert _agent_doc_path("/ws", "claude").name == "CLAUDE.md"
+
+
+# ── the ai-sdk package is chosen per turn from the model family ───────────────────────
+from server import _opencode_config # noqa: E402
+
+
+def _npm_for(model, provider):
+ d = tempfile.mkdtemp()
+ _opencode_config(Auth(api_key="k", base_url="https://relay.example/v1"), model, d, None, None,
+ None, provider)
+ return _json.loads(open(f"{d}/opencode.json").read())["provider"]["hr"]["npm"]
+
+
+def test_claude_on_an_anthropic_connection_uses_the_messages_package():
+ """A claude model on an anthropic-native connection speaks Messages, not chat/completions.
+ Sending it to the openai-compatible package fails at the first call."""
+ assert _npm_for("claude-sonnet-5", "anthropic") == "@ai-sdk/anthropic"
+
+
+def test_claude_through_the_router_also_uses_the_messages_package():
+ assert _npm_for("claude-opus-5", "tokenrouter") == "@ai-sdk/anthropic"
+
+
+def test_a_gpt_model_through_the_router_uses_the_responses_package():
+ assert _npm_for("gpt-5.4", "tokenrouter") == "@ai-sdk/openai"
+
+
+def test_everything_else_falls_to_openai_compatible():
+ assert _npm_for("qwen3.7-max", "openai-api") == "@ai-sdk/openai-compatible"
+ assert _npm_for("deepseek-v4-pro", "openai-api") == "@ai-sdk/openai-compatible"
diff --git a/ui/src/lib/harness.ts b/ui/src/lib/harness.ts
index 2cdb6af8..a8293de7 100644
--- a/ui/src/lib/harness.ts
+++ b/ui/src/lib/harness.ts
@@ -77,10 +77,9 @@ export const OOB: OobHarness[] = [
systemPrompt: 'You are DeepSeek Harness, an autonomous coding agent. You work on a real git workspace, running shell commands and editing files to complete the task end to end.',
tools: [], skills: [] },
{ id: 'opencode', name: 'OpenCode', version: 'v1.18.23', backend: 'opencode', status: 'ready',
- // ONE model on purpose. The server's catalogue seeds opencode with gpt-5.4 alone because no
- // model has yet been earned by a real turn on this backend; listing the usual multi-family set
- // here would advertise models the server would refuse and silently substitute.
- models: ['gpt-5.4'], defaultModel: 'gpt-5.4', moreModels: 0,
+ // Multi-family, matching the server catalogue: opencode reaches models through the same
+ // relays as pi, with the ai-sdk package chosen per turn from the model family.
+ models: ['gpt-5.4', 'gpt-5.6-sol', 'gpt-5.6-terra', 'gpt-5.6-luna', 'gpt-5.5', 'gpt-5.4-mini', 'gpt-5.2', 'gpt-5.3-codex', 'claude-opus-5', 'claude-fable-5', 'claude-opus-4.8', 'claude-sonnet-5', 'claude-opus-4.7', 'claude-sonnet-4.6', 'claude-haiku-4.5', 'gemini-3.6-flash', 'deepseek-v4-pro', 'deepseek-v4-flash', 'kimi-k3', 'kimi-k2.7-code', 'qwen3.7-max', 'qwen3.8-max', 'mistral-medium-3.5', 'step-3.7-flash'], defaultModel: 'gpt-5.4', moreModels: 0,
systemPrompt: 'You are OpenCode, an autonomous coding agent. You work on a real git workspace with shell and file access, reading and editing files and running commands to complete the task end to end.',
tools: [], skills: [] },
];