@@ -2,6 +2,7 @@ import type { StreamFn } from "@mariozechner/pi-agent-core";
22import { describe , expect , it , vi } from "vitest" ;
33import { applyExtraParamsToAgent } from "../pi-embedded-runner.js" ;
44import { resolveCacheRetention } from "./anthropic-cache-retention.js" ;
5+ import { isOpenRouterAnthropicModelRef } from "./anthropic-family-cache-semantics.js" ;
56
67function applyAndExpectWrapped ( params : {
78 cfg ?: Parameters < typeof applyExtraParamsToAgent > [ 1 ] ;
@@ -214,4 +215,34 @@ describe("cacheRetention default behavior", () => {
214215 resolveCacheRetention ( { cacheRetention : "short" } , "litellm" , "anthropic-messages" ) ,
215216 ) . toBe ( "short" ) ;
216217 } ) ;
218+
219+ it ( "does not treat non-Anthropic Bedrock models as cache-retention eligible" , ( ) => {
220+ expect (
221+ resolveCacheRetention (
222+ { cacheRetention : "long" } ,
223+ "amazon-bedrock" ,
224+ "openai-completions" ,
225+ "amazon.nova-micro-v1:0" ,
226+ ) ,
227+ ) . toBeUndefined ( ) ;
228+ } ) ;
229+
230+ it ( "keeps explicit cacheRetention for Anthropic Bedrock models" , ( ) => {
231+ expect (
232+ resolveCacheRetention (
233+ { cacheRetention : "long" } ,
234+ "amazon-bedrock" ,
235+ "openai-completions" ,
236+ "us.anthropic.claude-sonnet-4-5" ,
237+ ) ,
238+ ) . toBe ( "long" ) ;
239+ } ) ;
240+ } ) ;
241+
242+ describe ( "anthropic-family cache semantics" , ( ) => {
243+ it ( "classifies OpenRouter Anthropic model refs centrally" , ( ) => {
244+ expect ( isOpenRouterAnthropicModelRef ( "openrouter" , "anthropic/claude-opus-4-6" ) ) . toBe ( true ) ;
245+ expect ( isOpenRouterAnthropicModelRef ( "openrouter" , "google/gemini-2.5-pro" ) ) . toBe ( false ) ;
246+ expect ( isOpenRouterAnthropicModelRef ( "OpenRouter" , "Anthropic/Claude-Sonnet-4" ) ) . toBe ( true ) ;
247+ } ) ;
217248} ) ;
0 commit comments