fix(provider): select prompt cache keys by SDK - #38424
Merged
Merged
Conversation
Route cache affinity by npm package instead of logical provider ID so OpenAI-compatible endpoints, Azure opt-out, gateway auto-cache, and Anthropic automatic caching behave correctly.
Inline cache-key selection in options() by SDK package and drop the smallOptions caching path.
Azure gpt-5.5 returned before promptCacheKey was set after the cache block moved to the end of options().
3 tasks
sergical
added a commit
to sergical/opencode
that referenced
this pull request
Jul 26, 2026
Request-body construction inlined the provider policy and TTL projection, which packages/llm/AGENTS.md asks to keep behind named helpers so protocols stay comparable side by side. Move it to `automaticCacheControl`, and share the policy semantics with `applyCachePolicy` via exported `resolvePolicy` / `policyEnabled` rather than re-deriving "is caching on" by hand. Drop the `session_id` / `sessionID` options. OpenRouter does not document a session-affinity field, and anomalyco#38424 removed the equally undocumented `prompt_cache_key` for this provider four days ago. Drop the snake_case input spellings with them — AGENTS.md wants one way to construct a thing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
6 tasks
Bkm016
pushed a commit
to Bkm016/opencode
that referenced
this pull request
Jul 28, 2026
banlanzs
pushed a commit
to banlanzs/opencode
that referenced
this pull request
Aug 6, 2026
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.
Summary
promptCacheKey; DeepInfra / Cerebras →prompt_cache_keycaching: "auto"; skip Anthropic explicit breakpoints when automaticcacheControlis setSplit from #35982 (cache-key request shaping only; usage accounting and package patches deferred).
Mistral defaults may not hit the wire until the deferred SDK patch lands.
Test plan
bun test test/provider/transform.test.ts --test-name-pattern "setCacheKey|promptCache|prompt_cache|automatic caching|canonical sdk|azure"inpackages/opencodebun typecheckinpackages/opencode