From 50be3fc766374f03a4c7542e73e5ab2a55a256ba Mon Sep 17 00:00:00 2001 From: kilo-agent Date: Thu, 7 May 2026 12:22:46 +0000 Subject: [PATCH 1/4] refactor(cli): narrow kilocode_change markers around Responses-API guard Minimizes the diff from upstream opencode by restoring upstream's original reasoningSummary guard structure and comment, and scoping kilocode_change markers to only the Kilo-specific additions: two extra provider npm names and the new textVerbosity provider gate. --- packages/opencode/src/provider/transform.ts | 31 +++++++++++++-------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/packages/opencode/src/provider/transform.ts b/packages/opencode/src/provider/transform.ts index 0fddabb66bb..26c00748851 100644 --- a/packages/opencode/src/provider/transform.ts +++ b/packages/opencode/src/provider/transform.ts @@ -985,24 +985,32 @@ export function options(input: { } if (input.model.api.id.includes("gpt-5") && !input.model.api.id.includes("gpt-5-chat")) { - // kilocode_change start - guard OpenAI Responses-only params for compatible providers - const nativeOpenAI = [ - "@ai-sdk/openai", - "@ai-sdk/azure", - "@ai-sdk/github-copilot", - "@openrouter/ai-sdk-provider", - "@kilocode/kilo-gateway", - ].includes(input.model.api.npm) - if (!input.model.api.id.includes("gpt-5-pro")) { result["reasoningEffort"] = "medium" - if (nativeOpenAI) { + // Only inject reasoningSummary for providers that support it natively. + // @ai-sdk/openai-compatible proxies (e.g. LiteLLM) do not understand this + // parameter and return "Unknown parameter: 'reasoningSummary'". + if ( + input.model.api.npm === "@ai-sdk/openai" || + input.model.api.npm === "@ai-sdk/azure" || + input.model.api.npm === "@ai-sdk/github-copilot" || + input.model.api.npm === "@openrouter/ai-sdk-provider" || // kilocode_change + input.model.api.npm === "@kilocode/kilo-gateway" // kilocode_change + ) { result["reasoningSummary"] = "auto" } } + // Only set textVerbosity for non-chat gpt-5.x models + // Chat models (e.g. gpt-5.2-chat-latest) only support "medium" verbosity if ( - nativeOpenAI && + // kilocode_change start - gate textVerbosity to Responses-API providers + (input.model.api.npm === "@ai-sdk/openai" || + input.model.api.npm === "@ai-sdk/azure" || + input.model.api.npm === "@ai-sdk/github-copilot" || + input.model.api.npm === "@openrouter/ai-sdk-provider" || + input.model.api.npm === "@kilocode/kilo-gateway") && + // kilocode_change end input.model.api.id.includes("gpt-5.") && !input.model.api.id.includes("codex") && !input.model.api.id.includes("-chat") && @@ -1010,7 +1018,6 @@ export function options(input: { ) { result["textVerbosity"] = "low" } - // kilocode_change end if (input.model.providerID.startsWith("opencode")) { result["promptCacheKey"] = input.sessionID From fa759d41bcd445142dd1ec844f8af9d63b0bdd49 Mon Sep 17 00:00:00 2001 From: kilo-agent Date: Thu, 7 May 2026 12:32:09 +0000 Subject: [PATCH 2/4] address review: run fix-kilocode-markers on transform.ts - Reverts the nativeOpenAI refactor; restores upstream's reasoningSummary guard structure + comment so added npm entries stay inside a single marker block. - Includes the opencode textVerbosity comment that was dropped. - Also fixes pre-existing marker shape issues elsewhere in the same file flagged by script/upstream/fix-kilocode-markers.ts. --- packages/opencode/src/provider/transform.ts | 35 ++++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/packages/opencode/src/provider/transform.ts b/packages/opencode/src/provider/transform.ts index 26c00748851..61094a0e850 100644 --- a/packages/opencode/src/provider/transform.ts +++ b/packages/opencode/src/provider/transform.ts @@ -6,8 +6,10 @@ import type * as Provider from "./provider" import type * as ModelsDev from "./models" import { iife } from "@/util/iife" import { Flag } from "@opencode-ai/core/flag/flag" +// kilocode_change start import { kiloProviderOptions } from "@/kilocode/provider-options" -import { isLing } from "@/kilocode/model-match" // kilocode_change +import { isLing } from "@/kilocode/model-match" +// kilocode_change end type Modality = NonNullable["input"][number] @@ -43,8 +45,10 @@ function sdkKey(npm: string): string | undefined { return "gateway" case "@openrouter/ai-sdk-provider": return "openrouter" - case "@kilocode/kilo-gateway": // kilocode_change + // kilocode_change start + case "@kilocode/kilo-gateway": return "openrouter" + // kilocode_change end } return undefined } @@ -469,9 +473,11 @@ export function variants(model: Provider.Model): Record [effort, { reasoning: { effort } }])) case "@ai-sdk/gateway": @@ -913,11 +918,13 @@ export function options(input: { result["promptCacheKey"] = input.sessionID } + // kilocode_change start if ( input.model.api.npm === "@openrouter/ai-sdk-provider" || input.model.api.npm === "@llmgateway/ai-sdk-provider" || - input.model.api.npm === "@kilocode/kilo-gateway" // kilocode_change + input.model.api.npm === "@kilocode/kilo-gateway" ) { + // kilocode_change end result["usage"] = { include: true, } @@ -993,9 +1000,11 @@ export function options(input: { if ( input.model.api.npm === "@ai-sdk/openai" || input.model.api.npm === "@ai-sdk/azure" || + // kilocode_change start input.model.api.npm === "@ai-sdk/github-copilot" || - input.model.api.npm === "@openrouter/ai-sdk-provider" || // kilocode_change - input.model.api.npm === "@kilocode/kilo-gateway" // kilocode_change + input.model.api.npm === "@openrouter/ai-sdk-provider" || + input.model.api.npm === "@kilocode/kilo-gateway" + // kilocode_change end ) { result["reasoningSummary"] = "auto" } @@ -1063,11 +1072,13 @@ export function smallOptions(model: Provider.Model) { } return { thinkingConfig: { thinkingBudget: 0 } } } + // kilocode_change start if ( model.providerID === "openrouter" || model.providerID === "llmgateway" || - model.api.npm === "@kilocode/kilo-gateway" // kilocode_change + model.api.npm === "@kilocode/kilo-gateway" ) { + // kilocode_change end if (model.api.id.includes("google")) { return { reasoning: { enabled: false } } } From 9cec88dac12280071023dcb0607ae1759c9ac658 Mon Sep 17 00:00:00 2001 From: kilo-agent Date: Thu, 7 May 2026 12:53:32 +0000 Subject: [PATCH 3/4] minimize diff: keep only gpt-5 Responses-API block changes Revert the file-wide marker shape fixes from fix-kilocode-markers.ts since they touch unrelated code. Scope this PR to the two review findings in the gpt-5 block: - Replace nativeOpenAI refactor with upstream's if (===||===) form plus inline // kilocode_change markers on the added npm entries; restores the upstream reasoningSummary comment. - Restore the upstream textVerbosity comments, keep the new provider gate wrapped in kilocode_change start/end. --- packages/opencode/src/provider/transform.ts | 37 ++++++++------------- 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/packages/opencode/src/provider/transform.ts b/packages/opencode/src/provider/transform.ts index 61094a0e850..d0661232abc 100644 --- a/packages/opencode/src/provider/transform.ts +++ b/packages/opencode/src/provider/transform.ts @@ -6,10 +6,8 @@ import type * as Provider from "./provider" import type * as ModelsDev from "./models" import { iife } from "@/util/iife" import { Flag } from "@opencode-ai/core/flag/flag" -// kilocode_change start import { kiloProviderOptions } from "@/kilocode/provider-options" -import { isLing } from "@/kilocode/model-match" -// kilocode_change end +import { isLing } from "@/kilocode/model-match" // kilocode_change type Modality = NonNullable["input"][number] @@ -45,10 +43,8 @@ function sdkKey(npm: string): string | undefined { return "gateway" case "@openrouter/ai-sdk-provider": return "openrouter" - // kilocode_change start - case "@kilocode/kilo-gateway": + case "@kilocode/kilo-gateway": // kilocode_change return "openrouter" - // kilocode_change end } return undefined } @@ -473,11 +469,9 @@ export function variants(model: Provider.Model): Record [effort, { reasoning: { effort } }])) case "@ai-sdk/gateway": @@ -918,13 +913,11 @@ export function options(input: { result["promptCacheKey"] = input.sessionID } - // kilocode_change start if ( input.model.api.npm === "@openrouter/ai-sdk-provider" || input.model.api.npm === "@llmgateway/ai-sdk-provider" || - input.model.api.npm === "@kilocode/kilo-gateway" + input.model.api.npm === "@kilocode/kilo-gateway" // kilocode_change ) { - // kilocode_change end result["usage"] = { include: true, } @@ -1000,11 +993,9 @@ export function options(input: { if ( input.model.api.npm === "@ai-sdk/openai" || input.model.api.npm === "@ai-sdk/azure" || - // kilocode_change start - input.model.api.npm === "@ai-sdk/github-copilot" || - input.model.api.npm === "@openrouter/ai-sdk-provider" || - input.model.api.npm === "@kilocode/kilo-gateway" - // kilocode_change end + input.model.api.npm === "@ai-sdk/github-copilot" || // kilocode_change + input.model.api.npm === "@openrouter/ai-sdk-provider" || // kilocode_change + input.model.api.npm === "@kilocode/kilo-gateway" // kilocode_change ) { result["reasoningSummary"] = "auto" } @@ -1072,13 +1063,11 @@ export function smallOptions(model: Provider.Model) { } return { thinkingConfig: { thinkingBudget: 0 } } } - // kilocode_change start if ( model.providerID === "openrouter" || model.providerID === "llmgateway" || - model.api.npm === "@kilocode/kilo-gateway" + model.api.npm === "@kilocode/kilo-gateway" // kilocode_change ) { - // kilocode_change end if (model.api.id.includes("google")) { return { reasoning: { enabled: false } } } From 36a265520fe30b0a3601e630e56d7533f703b583 Mon Sep 17 00:00:00 2001 From: kilo-agent Date: Thu, 7 May 2026 14:48:31 +0000 Subject: [PATCH 4/4] drop restored upstream comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit They're upstream opencode comments, not kilo changes, so they shouldn't live inside kilocode_change markers — and outside the markers they add noise to this PR's diff. Drop them. --- packages/opencode/src/provider/transform.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/opencode/src/provider/transform.ts b/packages/opencode/src/provider/transform.ts index d0661232abc..35ea19b5f69 100644 --- a/packages/opencode/src/provider/transform.ts +++ b/packages/opencode/src/provider/transform.ts @@ -987,9 +987,6 @@ export function options(input: { if (input.model.api.id.includes("gpt-5") && !input.model.api.id.includes("gpt-5-chat")) { if (!input.model.api.id.includes("gpt-5-pro")) { result["reasoningEffort"] = "medium" - // Only inject reasoningSummary for providers that support it natively. - // @ai-sdk/openai-compatible proxies (e.g. LiteLLM) do not understand this - // parameter and return "Unknown parameter: 'reasoningSummary'". if ( input.model.api.npm === "@ai-sdk/openai" || input.model.api.npm === "@ai-sdk/azure" || @@ -1001,8 +998,6 @@ export function options(input: { } } - // Only set textVerbosity for non-chat gpt-5.x models - // Chat models (e.g. gpt-5.2-chat-latest) only support "medium" verbosity if ( // kilocode_change start - gate textVerbosity to Responses-API providers (input.model.api.npm === "@ai-sdk/openai" ||