mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-20 18:57:17 +03:00
feat(core): configure Anthropic cache breakpoints with compatibility.cacheFormat (#54945)
This commit is contained in:
committed by
GitHub
Unverified
parent
6a12383d3e
commit
69a71426ce
@@ -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"}')
|
||||
}),
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user