From 50982d31ab640f5722c93570e5fc77a2ba1fd4d4 Mon Sep 17 00:00:00 2001 From: chrarnoldus <12196001+chrarnoldus@users.noreply.github.com> Date: Mon, 10 Aug 2026 18:52:18 +0000 Subject: [PATCH] fix(cli): exclude gpt-5.6-terra models from explicit prompt cache breakpoints --- ...lude-terra-from-prompt-cache-breakpoint.md | 5 +++ packages/opencode/src/provider/transform.ts | 3 +- .../opencode/test/provider/transform.test.ts | 32 +++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 .changeset/exclude-terra-from-prompt-cache-breakpoint.md diff --git a/.changeset/exclude-terra-from-prompt-cache-breakpoint.md b/.changeset/exclude-terra-from-prompt-cache-breakpoint.md new file mode 100644 index 000000000000..ab9d9fa563df --- /dev/null +++ b/.changeset/exclude-terra-from-prompt-cache-breakpoint.md @@ -0,0 +1,5 @@ +--- +"@kilocode/cli": patch +--- + +Exclude GPT-5.6-Terra models from explicit prompt cache breakpoints. diff --git a/packages/opencode/src/provider/transform.ts b/packages/opencode/src/provider/transform.ts index 310c9d0c83c6..2595aa345273 100644 --- a/packages/opencode/src/provider/transform.ts +++ b/packages/opencode/src/provider/transform.ts @@ -328,13 +328,14 @@ function normalizeMessages( return msgs } -// kilocode_change start - explicit prompt cache breakpoints for GPT-5.6+ (excluding ChatGPT subscriptions) +// kilocode_change start - explicit prompt cache breakpoints for GPT-5.6+ (excluding ChatGPT subscriptions and unsupported variants) function isLikelyChatGPTSubscription(model: Provider.Model): boolean { return model.providerID === "openai" && model.cost?.input === 0 && model.cost?.output === 0 } function supportsPromptCacheBreakpoint(model: Provider.Model): boolean { if (isLikelyChatGPTSubscription(model)) return false + if (model.api.id.includes("terra")) return false const match = model.api.id.match(/gpt-(\d+)\.(\d+)/) if (match) { const major = Number(match[1]) diff --git a/packages/opencode/test/provider/transform.test.ts b/packages/opencode/test/provider/transform.test.ts index e834ec326eb8..b393acd58dec 100644 --- a/packages/opencode/test/provider/transform.test.ts +++ b/packages/opencode/test/provider/transform.test.ts @@ -3194,6 +3194,38 @@ describe("ProviderTransform.message - cache control on gateway", () => { expect(result[0].providerOptions?.openai?.promptCacheBreakpoint).toBeUndefined() expect(result[1].providerOptions?.openai?.promptCacheBreakpoint).toBeUndefined() }) + + test("openai gpt-5.6-terra does not apply promptCacheBreakpoint", () => { + const model = createModel({ + providerID: "openai", + api: { + id: "gpt-5.6-terra", + url: "https://api.openai.com/v1", + npm: "@ai-sdk/openai", + }, + id: "gpt-5.6-terra", + cost: { + input: 0.002, + output: 0.008, + cache: { read: 0.0005, write: 0.002 }, + }, + }) + const msgs = [ + { + role: "system", + content: "You are a helpful assistant", + }, + { + role: "user", + content: "Hello", + }, + ] as any[] + + const result = ProviderTransform.message(msgs, model, {}) as any[] + + expect(result[0].providerOptions?.openai?.promptCacheBreakpoint).toBeUndefined() + expect(result[1].providerOptions?.openai?.promptCacheBreakpoint).toBeUndefined() + }) // kilocode_change end })