@@ -1434,6 +1434,59 @@ describe("normalizeCompatibilityConfigValues", () => {
14341434 ] ) ;
14351435 } ) ;
14361436
1437+ it ( "keeps native Ollama params prototype-safe while setting num_ctx" , ( ) => {
1438+ const providerParams : Record < string , unknown > = { temperature : 0.2 } ;
1439+ Object . defineProperty ( providerParams , "__proto__" , {
1440+ enumerable : true ,
1441+ value : { think : "high" } ,
1442+ } ) ;
1443+ const modelParams : Record < string , unknown > = { top_p : 0.9 } ;
1444+ Object . defineProperty ( modelParams , "__proto__" , {
1445+ enumerable : true ,
1446+ value : { keep_alive : "forever" } ,
1447+ } ) ;
1448+
1449+ const res = normalizeCompatibilityConfigValues ( {
1450+ models : {
1451+ providers : {
1452+ ollama : {
1453+ baseUrl : "http://localhost:11434" ,
1454+ api : "ollama" ,
1455+ contextWindow : 65536 ,
1456+ params : providerParams ,
1457+ models : [
1458+ ollamaModel ( {
1459+ contextWindow : 32768 ,
1460+ params : modelParams ,
1461+ } ) ,
1462+ ] ,
1463+ } ,
1464+ } ,
1465+ } ,
1466+ } ) ;
1467+
1468+ const nextProviderParams = res . config . models ?. providers ?. ollama ?. params as Record <
1469+ string ,
1470+ unknown
1471+ > ;
1472+ const nextModelParams = res . config . models ?. providers ?. ollama ?. models ?. [ 0 ] ?. params as Record <
1473+ string ,
1474+ unknown
1475+ > ;
1476+ expect ( Object . getPrototypeOf ( nextProviderParams ) ) . toBe ( Object . prototype ) ;
1477+ expect ( Object . getPrototypeOf ( nextModelParams ) ) . toBe ( Object . prototype ) ;
1478+ expect ( Object . getOwnPropertyDescriptor ( nextProviderParams , "__proto__" ) ?. value ) . toEqual ( {
1479+ think : "high" ,
1480+ } ) ;
1481+ expect ( Object . getOwnPropertyDescriptor ( nextModelParams , "__proto__" ) ?. value ) . toEqual ( {
1482+ keep_alive : "forever" ,
1483+ } ) ;
1484+ expect ( nextProviderParams . think ) . toBeUndefined ( ) ;
1485+ expect ( nextModelParams . keep_alive ) . toBeUndefined ( ) ;
1486+ expect ( nextProviderParams . num_ctx ) . toBe ( 65536 ) ;
1487+ expect ( nextModelParams . num_ctx ) . toBe ( 32768 ) ;
1488+ } ) ;
1489+
14371490 it ( "keeps existing provider-level native Ollama params.num_ctx ahead of inherited provider budgets" , ( ) => {
14381491 const res = normalizeCompatibilityConfigValues ( {
14391492 models : {
0 commit comments