Skip to content

ci: fix/anthropic-cache-format - #1

Closed
mkowalski wants to merge 1 commit into
mainfrom
fix/anthropic-cache-format
Closed

mkowalski wants to merge 1 commit into
mainfrom
fix/anthropic-cache-format

Conversation

@mkowalski

Copy link
Copy Markdown
Owner

Fork-internal PR to run CI for upstream yuseferi#44 / yuseferi#45. Not for merge.

OpenCode 2's OpenAI-compatible Chat Completions runtime only places
Anthropic-style `cache_control` breakpoints when the model declares
`compatibility.cacheFormat`. Discovered models never did, so Claude served
through LiteLLM lost prompt caching on OpenCode 2 (yuseferi#42).

Record per model whether `/v1/model/info` lists `cache_control` under
`supported_openai_params` and register Chat Completions models that do with
`compatibility.cacheFormat: "anthropic"`. Only the Chat Completions runtimes
read the setting: the Anthropic Messages runtime adds its own breakpoints
and the Responses runtimes do not use it, so models on those packages are
left alone. The hint travels with the discovery result and the disk cache
(`CACHE_VERSION` 4).

Add the `modelCompatibility` provider option, a per-model map like
`modelCapabilities`, to set `cacheFormat` to `"anthropic"`, `"alibaba"` or
`null`. OpenCode's own `providers.<id>.models.<model>.compatibility` is
merged over the plugin's value, so it can add or change a key but not
remove one the plugin inferred; `null` here does that. Values are validated
when parsed, because OpenCode validates plugin-registered models only when
it serializes them, where one bad value fails the whole model list. It
accepts only `cacheFormat`; it is applied when models are registered, so it
is not part of the cache key.

Fixes yuseferi#42

Signed-off-by: Mateusz Kowalski <mateusz@mkowalski.com>
Assisted-By: Claude Fable 5.1
@mkowalski mkowalski closed this Oct 19, 2026
@mkowalski mkowalski reopened this Oct 19, 2026
@mkowalski mkowalski closed this Oct 19, 2026
@mkowalski
mkowalski deleted the fix/anthropic-cache-format branch October 20, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant