From fb4cf1b0354b87df57f7f60c0430e4c4b4bcf8d2 Mon Sep 17 00:00:00 2001 From: OpenCode Test Date: Thu, 8 Jan 2026 13:46:38 -0800 Subject: [PATCH] fix(external-llm): correct opencode CLI syntax and gemini routing - OpenCode: use `opencode run -m MODEL "prompt"` syntax - OpenCode: set correct binary path (/home/linuxbrew/.linuxbrew/bin/opencode) - Gemini: route long-context to gemini-2.5-pro (gemini-3 not available yet) Tested working: - opencode/big-pickle - github-copilot/claude-sonnet-4.5 - zai-coding-plan/glm-4.7 - gemini/gemini-2.5-pro - gemini/gemini-2.5-flash Co-Authored-By: Claude Opus 4.5 --- mcp/llm-router/providers/opencode.py | 8 ++++++-- state/model-policy.json | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mcp/llm-router/providers/opencode.py b/mcp/llm-router/providers/opencode.py index ebc0f35..21a1e56 100755 --- a/mcp/llm-router/providers/opencode.py +++ b/mcp/llm-router/providers/opencode.py @@ -4,6 +4,9 @@ import subprocess from typing import List +# OpenCode binary path (linuxbrew installation) +OPENCODE_BIN = "/home/linuxbrew/.linuxbrew/bin/opencode" + def invoke(cli_args: List[str], prompt: str, timeout: int = 300) -> str: """ @@ -22,9 +25,10 @@ def invoke(cli_args: List[str], prompt: str, timeout: int = 300) -> str: TimeoutError: If request exceeds timeout Example invocation: - opencode -m github-copilot/gpt-5.2 -p "Hello world" + opencode run -m github-copilot/gpt-5.2 "Hello world" """ - cmd = ["opencode"] + cli_args + ["-p", prompt] + # Build command: opencode run -m MODEL "prompt" + cmd = [OPENCODE_BIN, "run"] + cli_args + [prompt] try: result = subprocess.run( diff --git a/state/model-policy.json b/state/model-policy.json index f917d1c..9bfa12f 100644 --- a/state/model-policy.json +++ b/state/model-policy.json @@ -190,7 +190,7 @@ "task_routing": { "reasoning": "github-copilot/gpt-5.2", "code-generation": "zai-coding-plan/glm-4.7", - "long-context": "gemini/gemini-3-pro", + "long-context": "gemini/gemini-2.5-pro", "default": "github-copilot/claude-sonnet-4.5" } }