-
Notifications
You must be signed in to change notification settings - Fork 336
feat(ai): default claude-* models to automatic Anthropic prompt caching #3923
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
d2629fd
c269e78
483ba5f
00d3203
9dc8a8d
b3f7ba2
03a9bfd
de8d673
9571318
4c71ba5
9c8cc83
ec62d52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -447,6 +447,15 @@ function dropAnthropicStrictTools(params: MessageCreateParamsStreaming): void { | |
| } | ||
| } | ||
|
|
||
| function isClaudeFamilyModel(model: Model<"anthropic-messages">): boolean { | ||
| // Classify the same identifier the request body serializes (`params.model = | ||
| // model.id` in buildParams); a differing `wireModelId` is not dispatched by | ||
| // this transport, so it must not drive the cache decision either. | ||
| const id = model.id; | ||
| const shortId = id.includes("/") ? id.slice(id.lastIndexOf("/") + 1) : id; | ||
| return shortId.toLowerCase().startsWith("claude-"); | ||
| } | ||
|
|
||
| function getCacheControl( | ||
| model: Model<"anthropic-messages">, | ||
| baseUrl: string, | ||
|
|
@@ -462,7 +471,7 @@ function getCacheControl( | |
| ? "none" | ||
| : promptCacheMode === "explicit" | ||
| ? "explicit" | ||
| : isCanonicalApi | ||
| : isCanonicalApi || isClaudeFamilyModel(model) | ||
| ? "automatic" | ||
| : "none"; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a non-Claude model on a noncanonical Anthropic-compatible endpoint sets the newly accepted Useful? React with 👍 / 👎. |
||
| if (mode === "none") return { mode }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a user-defined
anthropic-messagesendpoint exposes aclaude-*model but rejects top-levelcache_controland requires block-level markers, this identifier-only default now makes every request fail upstream. The updatedAnthropicCompatdocumentation explicitly recognizes such endpoints and recommendspromptCacheMode: "explicit", but the coding-agent models configuration still validatescompatwithOpenAICompatSchema, which does not admitpromptCacheMode, so CLI users cannot select that advertised mode (short of disabling caching entirely withcacheRetention: "none"). Restrict this default to known-capable endpoints or expose the Anthropic compatibility setting through the configuration schema.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9dc8a8d. The shared models compatibility schema now admits
compat.promptCacheMode(none,explicit,automatic) andcompat.supportsLongCacheRetentionat provider, model, and model-override levels; the generatedschemas/models.schema.jsonis updated. Focused schema validation andModelRegistrypropagation/precedence tests cover all three configuration levels. The branch is also merged with currentdev, and Anthropic/config/package checks are clean.