fix(connect): OpenCode contextWindowSize nutzt echten Modell-Kontext

openCodeBlock() baut jetzt Modell-Objekte statt nur ID-Strings, damit
m.meta.ctx ausgelesen werden kann. contextWindowSize wird korrekt auf
den konfigurierten Kontext gesetzt (Standard: 131072 = 128k).

Vorher: { "name": "coder" }  (kein Kontexthinweis → AI-SDK-Default)
Nachher: { "name": "coder", "contextWindowSize": 131072 }

Identisches Problem wie bei Zed max_tokens (war 32768 hardcoded).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Hitonabi
2026-06-22 22:25:52 +02:00
parent d8fe1f8097
commit f536f454ba
2 changed files with 18 additions and 12 deletions
+8 -2
View File
@@ -33,8 +33,14 @@
}
function openCodeBlock(url: string, ids: string[]) {
const list = ids.length ? ids : (allModels.length ? allModels.map((m: any) => m.name) : ['coder'])
const modelMap = list.map((id: string) => ` "${id}": { "name": "${id}" }`).join(',\n')
// Modell-Objekte mit Meta (für ctx) statt nur IDs
const ms = ids.length
? allModels.filter((m: any) => ids.includes(m.name))
: (allModels.length ? allModels : [{ name: 'coder', meta: {} }])
const modelMap = ms.map((m: any) => {
const ctx = m.meta?.ctx || 131072 // konfigurierten Kontext übergeben (Standard: 128k)
return ` "${m.name}": { "name": "${m.name}", "contextWindowSize": ${ctx} }`
}).join(',\n')
return `"provider": {\n "llama-swap": {\n "npm": "@ai-sdk/openai-compatible",\n "name": "Bosgame (llama-swap)",\n "options": {\n "baseURL": "${url}",\n "apiKey": "local"\n },\n "models": {\n${modelMap}\n }\n }\n}`
}