From 05747b02ab2ec3f94075bca97c370fbc62c2bb32 Mon Sep 17 00:00:00 2001 From: Daniel Hiltgen Date: Tue, 2 Jun 2026 10:50:35 -0700 Subject: [PATCH] launch: fix opencode local model limits (#16425) Local model metadata from /api/tags can include a context length without a max output limit, so omit OpenCode limit stanzas unless an output limit is known. This preserves the pre-0.30 OpenCode behavior: local models did not receive a limit stanza because /api/tags did not expose context length, while cloud models still emit complete context/output limits. Fixes #16424 --- cmd/launch/opencode.go | 6 ++---- cmd/launch/opencode_test.go | 8 ++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cmd/launch/opencode.go b/cmd/launch/opencode.go index 98dbf440f..d0a6d7d3b 100644 --- a/cmd/launch/opencode.go +++ b/cmd/launch/opencode.go @@ -278,14 +278,12 @@ func buildModelEntries(modelList []LaunchModel) map[string]any { "output": []string{"text"}, } } - if model.ContextLength > 0 || model.MaxOutputTokens > 0 { + if model.MaxOutputTokens > 0 { limit := make(map[string]any) if model.ContextLength > 0 { limit["context"] = model.ContextLength } - if model.MaxOutputTokens > 0 { - limit["output"] = model.MaxOutputTokens - } + limit["output"] = model.MaxOutputTokens entry["limit"] = limit } models[model.Name] = entry diff --git a/cmd/launch/opencode_test.go b/cmd/launch/opencode_test.go index e43f78ab1..45efff5e0 100644 --- a/cmd/launch/opencode_test.go +++ b/cmd/launch/opencode_test.go @@ -196,6 +196,14 @@ func TestBuildModelEntries(t *testing.T) { t.Fatalf("limit = %v, want context/output", limit) } }) + + t.Run("omits context-only limits", func(t *testing.T) { + models := buildModelEntries([]LaunchModel{{Name: "qwen2.5:0.5b", ContextLength: 32768}}) + entry, _ := models["qwen2.5:0.5b"].(map[string]any) + if _, ok := entry["limit"]; ok { + t.Fatalf("limit should be omitted when output limit is unknown, got %v", entry["limit"]) + } + }) } func TestOpenCodeModels_ReturnsNil(t *testing.T) {