@@ -32,6 +32,7 @@ import { Flag } from "../flag/flag"
3232import type { ModelsDev } from "../provider/models"
3333import { Installation } from "../installation"
3434import { Config } from "../config/config"
35+ import { ProviderTransform } from "../provider/transform"
3536
3637export namespace Session {
3738 const log = Log . create ( { service : "session" } )
@@ -266,15 +267,6 @@ export namespace Session {
266267 ( x ) : CoreMessage => ( {
267268 role : "system" ,
268269 content : x ,
269- providerOptions : {
270- ...( input . providerID === "anthropic"
271- ? {
272- anthropic : {
273- cacheControl : { type : "ephemeral" } ,
274- } ,
275- }
276- : { } ) ,
277- } ,
278270 } ) ,
279271 ) ,
280272 ...convertToCoreMessages ( [
@@ -284,7 +276,9 @@ export namespace Session {
284276 parts : toParts ( input . parts ) ,
285277 } ,
286278 ] ) ,
287- ] ,
279+ ] . map ( ( msg , i ) =>
280+ ProviderTransform . message ( msg , i , input . providerID , input . modelID ) ,
281+ ) ,
288282 model : model . language ,
289283 } )
290284 . then ( ( result ) => {
@@ -515,24 +509,17 @@ export namespace Session {
515509 maxSteps : 1000 ,
516510 messages : [
517511 ...system . map (
518- ( x , index ) : CoreMessage => ( {
512+ ( x ) : CoreMessage => ( {
519513 role : "system" ,
520514 content : x ,
521- providerOptions : {
522- ...( input . providerID === "anthropic" && index < 4
523- ? {
524- anthropic : {
525- cacheControl : { type : "ephemeral" } ,
526- } ,
527- }
528- : { } ) ,
529- } ,
530515 } ) ,
531516 ) ,
532517 ...convertToCoreMessages (
533518 msgs . map ( toUIMessage ) . filter ( ( x ) => x . parts . length > 0 ) ,
534519 ) ,
535- ] ,
520+ ] . map ( ( msg , i ) =>
521+ ProviderTransform . message ( msg , i , input . providerID , input . modelID ) ,
522+ ) ,
536523 temperature : model . info . temperature ? 0 : undefined ,
537524 tools : {
538525 ...tools ,
0 commit comments