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.

Studio: send the OpenCode Go session header on the older /zen/go base URL (#15981)

Daniel Han287844f5bb09
diff --git a/studio/backend/core/inference/external_provider.py b/studio/backend/core/inference/external_provider.py
index a83c2585d93..69b979742bf 100644
--- a/studio/backend/core/inference/external_provider.py
+++ b/studio/backend/core/inference/external_provider.py
@@ -1673,7 +1673,11 @@ class ExternalProviderClient:
if (
base.scheme == "https"
and base.hostname == "opencode.ai"
- and (base.path == "/inference/go" or base.path.startswith("/inference/go/"))
+ # /zen/go is the older Go base URL; the gateway still serves and enforces it.
+ and any(
+ base.path == prefix or base.path.startswith(prefix + "/")
+ for prefix in ("/inference/go", "/zen/go")
+ )
):
# Hashed so the raw conversation ID never leaves Studio; titles and probes have no thread.
headers["x-opencode-session"] = (
diff --git a/studio/backend/tests/test_opencode_go_session.py b/studio/backend/tests/test_opencode_go_session.py
index 8fc9bd73c74..7050596a940 100644
--- a/studio/backend/tests/test_opencode_go_session.py
+++ b/studio/backend/tests/test_opencode_go_session.py
@@ -11,7 +11,10 @@ from core.inference import external_provider as ep
@pytest.mark.parametrize("stream", [True, False])
-def test_opencode_go_chat_sends_conversation_session(monkeypatch, stream):
+ "base_url", ["https://opencode.ai/inference/go/v1", "https://opencode.ai/zen/go/v1"]
+)
+def test_opencode_go_chat_sends_conversation_session(monkeypatch, stream, base_url):
requests = []
def handler(request):
@@ -27,9 +30,7 @@ def test_opencode_go_chat_sends_conversation_session(monkeypatch, stream):
async def run():
async with httpx.AsyncClient(transport = httpx.MockTransport(handler)) as http:
monkeypatch.setattr(ep, "_client", lambda: http)
- client = ep.ExternalProviderClient(
- "custom", "https://opencode.ai/inference/go/v1", "key"
- )
+ client = ep.ExternalProviderClient("custom", base_url, "key")
for thread_id in ("conversation-1", "conversation-1", "conversation-2"):
async for _ in client.stream_chat_completion(
messages = [{"role": "user", "content": "hi"}],
@@ -46,7 +47,10 @@ def test_opencode_go_chat_sends_conversation_session(monkeypatch, stream):
assert sessions[2] and sessions[2] != sessions[0]
[email protected]("base_url", ["https://example.org/v1", "https://opencode.ai/inference/v1"])
+ "base_url",
+ ["https://example.org/v1", "https://opencode.ai/inference/v1", "https://opencode.ai/zen/v1"],
+)
def test_other_providers_do_not_receive_opencode_session(monkeypatch, base_url):
requests = []