feat(core): configure Anthropic cache breakpoints with compatibility.cacheFormat (#54945)

This commit is contained in:
Aiden Cline
2026-10-12 20:23:14 -05:00
committed by GitHub
Unverified
parent 6a12383d3e
commit 69a71426ce
15 changed files with 196 additions and 14 deletions
@@ -170,6 +170,31 @@ describe("ConfigProviderPlugin.Plugin", () => {
}),
)
it.effect("carries a configured provider cache format to the runtime model", () =>
Effect.gen(function* () {
const models = yield* Model.Service
yield* addPlugin([
new Document({
type: "document",
info: decode({
providers: {
litellm: {
package: "@opencode/ai/providers/openai-compatible",
settings: { baseURL: "https://litellm.test/v1" },
compatibility: { cacheFormat: "anthropic" },
models: { "claude-sonnet-5": {} },
},
},
}),
}),
])
const model = required(yield* models.get(Provider.ID.make("litellm"), Model.ID.make("claude-sonnet-5")))
expect(model.compatibility).toEqual({ cacheFormat: "anthropic" })
expect((yield* ModelResolver.fromCatalogModel(model)).compatibility?.cacheFormat).toBe("anthropic")
}),
)
it.effect("applies provider compatibility to every provider model with model overrides", () =>
Effect.gen(function* () {
const providers = yield* Provider.Service
@@ -192,6 +192,8 @@ it.live("manual PAT uses its account and native compatibility rather than an SDK
const body = yield* Effect.promise(() => request.json())
expect(body).toMatchObject({ model: modelID, max_completion_tokens: 1024 })
expect(body).not.toHaveProperty("max_tokens")
// Cortex caches Claude only through explicit Anthropic-style breakpoints.
expect(JSON.stringify(body)).toContain('"cache_control":{"type":"ephemeral"}')
}),
),
)