Repository navigation
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fork-internal PR to run CI for upstream yuseferi#44 / yuseferi#45. Not for merge.