Skip to content

ci: fix/anthropic-variant-settings - #2

Closed
mkowalski wants to merge 2 commits into
mainfrom
fix/anthropic-variant-settings
Closed

mkowalski wants to merge 2 commits into
mainfrom
fix/anthropic-variant-settings

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
Discovered reasoning-effort variants set `reasoningEffort`, which only the
OpenAI runtimes read. On OpenCode 2 a provider can use
`@opencode/ai/providers/anthropic` or `anthropic-compatible` to reach Claude
through the proxy's `/v1/messages`; there every variant was a silent no-op.

Record whether `/v1/model/info` reports `supports_adaptive_thinking` and
`thinking_always_on`, and on Anthropic packages emit each level as
`{ thinking: { type: "adaptive", display: "summarized" }, effort }`, the
shape OpenCode's own catalog uses for adaptive-thinking Claude models.
`none` becomes `thinking: { type: "disabled" }` and is dropped when thinking
is always on. Models without adaptive thinking get no variants on those
packages rather than inert ones. OpenAI packages are unchanged.

Cache entries written before this change carry neither hint, so
`CACHE_VERSION` moves to 5 and such caches are rediscovered.

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
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