refactor(cli): simplify ChatGPT subscription detection to zero-cost heuristic

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
This commit is contained in:
chrarnoldus
2026-08-10 13:04:02 +00:00
co-authored by kiloconnect[bot]
parent 2e5199a40d
commit 9b820d2f9d
2 changed files with 4 additions and 38 deletions
+3 -5
View File
@@ -329,14 +329,12 @@ function normalizeMessages(
}
// kilocode_change start - explicit prompt cache breakpoints for GPT-5.6+ (excluding ChatGPT subscriptions)
function isChatGPTSubscription(model: Provider.Model): boolean {
if (model.providerID === "openai" && model.cost?.input === 0 && model.cost?.output === 0) return true
if (typeof model.api.url === "string" && model.api.url.includes("chatgpt.com")) return true
return false
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 (isChatGPTSubscription(model)) return false
if (isLikelyChatGPTSubscription(model)) return false
const match = model.api.id.match(/gpt-(\d+)\.(\d+)/)
if (match) {
const major = Number(match[1])
@@ -3163,7 +3163,7 @@ describe("ProviderTransform.message - cache control on gateway", () => {
})
})
test("openai gpt-5.6 with ChatGPT subscription (zero cost) does not apply promptCacheBreakpoint", () => {
test("openai gpt-5.6 with ChatGPT subscription (zero cost heuristic) does not apply promptCacheBreakpoint", () => {
const model = createModel({
providerID: "openai",
api: {
@@ -3194,38 +3194,6 @@ 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 with ChatGPT backend endpoint does not apply promptCacheBreakpoint", () => {
const model = createModel({
providerID: "openai",
api: {
id: "gpt-5.6",
url: "https://chatgpt.com/backend-api/codex/responses",
npm: "@ai-sdk/openai",
},
id: "gpt-5.6",
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
})