Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/exclude-terra-from-prompt-cache-breakpoint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@kilocode/cli": patch
---

Exclude GPT-5.6-Terra models from explicit prompt cache breakpoints.
3 changes: 2 additions & 1 deletion packages/opencode/src/provider/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: Consider matching -terra instead of a bare terra substring

includes("terra") matches anywhere in the model id, so a hypothetical future non-Terra model whose name merely contains the substring (e.g. a terraform-themed variant) would silently lose explicit breakpoints. includes("-terra") would still catch gpt-5.6-terra and prefixed gateway ids like openai/gpt-5.6-terra while avoiding that false positive. This is consistent with the broad includes checks already used nearby (claude, anthropic), and the failure mode is a graceful fallback to automatic caching, so feel free to reject.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

const match = model.api.id.match(/gpt-(\d+)\.(\d+)/)
if (match) {
const major = Number(match[1])
Expand Down
32 changes: 32 additions & 0 deletions packages/opencode/test/provider/transform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
})

Expand Down
Loading