chore(llm): make cache: 'auto' the default (#26798)

This commit is contained in:
Kit Langton
2026-05-10 22:46:01 -04:00
committed by GitHub
parent 721ff5121e
commit 9b369ee815
8 changed files with 41 additions and 17 deletions

View File

@@ -24,15 +24,15 @@ const AUTO: CachePolicyObject = {
const NONE: CachePolicyObject = {}
// Resolution rules:
// - undefined → "none" (opt-in default so the policy never changes wire
// shape for existing callers; downstream code can flip to
// `cache: "auto"` once they audit the placement choices).
// - "auto" → the recommended policy: tools + system + latest user msg.
// - undefined → "auto" — caching is on by default. The math favors it:
// Anthropic 5m-cache write is 1.25x base, read is 0.1x,
// so a single reuse within 5 minutes already wins.
// - "auto" → tools + system + latest user msg.
// - "none" → no auto placement; manual `CacheHint`s still flow.
// - object form → exactly what the caller asked for.
const resolve = (policy: CachePolicy | undefined): CachePolicyObject => {
if (policy === undefined || policy === "none") return NONE
if (policy === "auto") return AUTO
if (policy === undefined || policy === "auto") return AUTO
if (policy === "none") return NONE
return policy
}