You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
V1→V2 migration silently drops prompt caching for OpenAI-compatible Claude endpoints #65400
A V1 config that served Claude through an OpenAI-compatible endpoint got cache_control breakpoints. On V2 the same config sends none, so every turn bills as uncached input, with no warning.
migrate-v1 says supported V1 behaviour that stops working in V2 is a compatibility bug, and lists the intentional breaks under Accepted but unsupported fields. Prompt caching isn't among them.
The removal was deliberate: V1 placed markers whenever the model id contained claude (transform.ts); V2 only marks routes in RESPECTS_INLINE_HINTS, which excludes openai-compatible-chat (cache-policy.ts). compatibility.cacheFormat is the documented opt-in (#54945), but migrate.ts never infers it, though it already rewrites the adjacent setCacheKey → supportsPromptCacheKey.
Expected: the migration infers cacheFormat: "anthropic" for models that matched the V1 heuristic, or warns that caching was dropped. migrate-v1 currently documents setCacheKey and the cache-cost rename, not cacheFormat.
OpenCode version
1.19.6 (opencode-ai) → 2.3.2 (@opencode/cli). The opt-in landed in 2.0.28.
Point baseURL at a proxy that logs request bodies, then run opencode run hi -m gateway/claude-sonnet-5-5:
1.19.6: cache_control on /messages/0, /messages/1, /messages/2
2.3.2: no cache_control anywhere
Adding "compatibility": { "cacheFormat": "anthropic" } doesn't fix it in the V1 provider block — that schema has no compatibility field, so the key is dropped silently. It only works after rewriting the block to the V2 providers shape.
Seen with a simulated model or a mock server, not a real provider; a maintainer should confirm.
Thanks for the detailed report. I reproduced this on 2.3.2 and it still happens on the latest dev (ba5bbef).
I ran the released CLI against a local mock OpenAI-compatible server that only logs request bodies and sends back a short reply. The mock stood in for your proxy; what's being checked is what OpenCode sends. Then I ran opencode run hi -m gateway/claude-sonnet-5-5 with your config and counted cache_control in the logged requests:
1.19.6, your V1 provider block: 5 markers
2.3.2 and dev, your V1 provider block: 0
2.3.2 and dev, same block with compatibility.cacheFormat: "anthropic" added: still 0, so the key is dropped silently
2.3.2 and dev, block rewritten to the V2 providers shape with cacheFormat: 6
So the opt-in itself works, but migrating a V1 config loses caching without a warning. The script below reproduces it.
Confirmed — the migration keeps setCacheKey but never carries over the V1 claude-id cache heuristic, so an OpenAI-compatible Claude provider loses its cache markers and every turn bills as uncached input. Preparing a PR that infers compatibility.cacheFormat: "anthropic" for those models during migration.
Activity
opencodejr commentedon Nov 21, 2026
Seen with a simulated model or a mock server, not a real provider; a maintainer should confirm.
Thanks for the detailed report. I reproduced this on 2.3.2 and it still happens on the latest
dev(ba5bbef).I ran the released CLI against a local mock OpenAI-compatible server that only logs request bodies and sends back a short reply. The mock stood in for your proxy; what's being checked is what OpenCode sends. Then I ran
opencode run hi -m gateway/claude-sonnet-5-5with your config and countedcache_controlin the logged requests:providerblock: 5 markersdev, your V1providerblock: 0dev, same block withcompatibility.cacheFormat: "anthropic"added: still 0, so the key is dropped silentlydev, block rewritten to the V2providersshape withcacheFormat: 6So the opt-in itself works, but migrating a V1 config loses caching without a warning. The script below reproduces it.
Reproduction script (repro.sh)
Run it:
bash repro.shDZH166 commentedon Nov 21, 2026
Confirmed — the migration keeps
setCacheKeybut never carries over the V1 claude-id cache heuristic, so an OpenAI-compatible Claude provider loses its cache markers and every turn bills as uncached input. Preparing a PR that inferscompatibility.cacheFormat: "anthropic"for those models during migration.fix(core): keep migrated openai-compatible Claude models on prompt ca…
fix(core): keep migrated openai-compatible Claude models on prompt ca…
fix(core): keep migrated openai-compatible Claude models on prompt ca…
fix(core): keep migrated openai-compatible Claude models on prompt ca…
fix(core): keep migrated openai-compatible Claude models on prompt ca…