@@ -860,6 +860,7 @@ describe("composer fallback to another instance of the same driver", () => {
860860 readonly providers : ReadonlyArray < ServerProvider > ;
861861 readonly draft ?: Parameters < typeof deriveEffectiveComposerModelState > [ 0 ] [ "draft" ] ;
862862 readonly threadModelSelection : ReturnType < typeof createModelSelection > ;
863+ readonly customModels ?: Partial < Record < string , ReadonlyArray < string > > > ;
863864 } ) {
864865 const settings = {
865866 ...DEFAULT_UNIFIED_SETTINGS ,
@@ -869,7 +870,13 @@ describe("composer fallback to another instance of the same driver", () => {
869870 {
870871 driver : provider . driver ,
871872 enabled : provider . enabled ,
872- config : { } ,
873+ config : {
874+ customModels : ( input . customModels ?. [ provider . instanceId ] ?? [ ] ) . map ( ( slug ) => ( {
875+ slug,
876+ name : slug ,
877+ capabilities : null ,
878+ } ) ) ,
879+ } ,
873880 } ,
874881 ] ) ,
875882 ) ,
@@ -954,6 +961,138 @@ describe("composer fallback to another instance of the same driver", () => {
954961 expect ( traits . modelOptionsForDispatch ) . toBeUndefined ( ) ;
955962 } ) ;
956963
964+ describe ( "with model aliases" , ( ) => {
965+ const reasoningModel = (
966+ slug : string ,
967+ id : string ,
968+ extra : Partial < ServerProvider [ "models" ] [ number ] > = { } ,
969+ ) : ServerProvider [ "models" ] [ number ] => ( {
970+ slug,
971+ name : slug ,
972+ isCustom : false ,
973+ ...extra ,
974+ capabilities : {
975+ optionDescriptors : [
976+ {
977+ id,
978+ label : id ,
979+ type : "select" ,
980+ options : [ "medium" , "high" , "xhigh" ] . map ( ( value ) => ( {
981+ id : value ,
982+ label : value ,
983+ isDefault : value === "medium" ,
984+ } ) ) ,
985+ } ,
986+ ] ,
987+ } ,
988+ } ) ;
989+
990+ it . each ( [
991+ [ "5.4" , "gpt-5.4" ] ,
992+ [ "gpt-5-codex" , "gpt-5.4" ] ,
993+ [ "gpt-5.4" , "5.4" ] ,
994+ ] ) ( "keeps the effort from %s on fallback %s" , ( savedModel , fallbackModel ) => {
995+ const disabledCodex = ProviderInstanceId . make ( "codex" ) ;
996+ const fallbackCodex = ProviderInstanceId . make ( "codex_team" ) ;
997+ const models = [ reasoningModel ( fallbackModel , "reasoningEffort" ) ] ;
998+ const { selectedInstanceId, state, traits } = composerFor ( {
999+ providers : [
1000+ { ...provider ( { provider : codex , instanceId : disabledCodex } ) , enabled : false , models } ,
1001+ { ...provider ( { provider : codex , instanceId : fallbackCodex } ) , models } ,
1002+ ] ,
1003+ threadModelSelection : createModelSelection ( disabledCodex , savedModel , [
1004+ { id : "reasoningEffort" , value : "xhigh" } ,
1005+ ] ) ,
1006+ } ) ;
1007+
1008+ expect ( selectedInstanceId ) . toBe ( fallbackCodex ) ;
1009+ expect ( state . selectedModel ) . toBe ( fallbackModel ) ;
1010+ expect ( traits . promptEffort ) . toBe ( "xhigh" ) ;
1011+ } ) ;
1012+
1013+ it . each ( [
1014+ {
1015+ // A disabled Codex instance reports only its custom models.
1016+ state : "disabled" ,
1017+ requested : {
1018+ enabled : false ,
1019+ models : [ reasoningModel ( "5.4" , "reasoningEffort" , { isCustom : true } ) ] ,
1020+ } ,
1021+ } ,
1022+ {
1023+ // An unavailable instance reports no models; its custom models are only in settings.
1024+ state : "unavailable" ,
1025+ requested : { enabled : false , availability : "unavailable" as const , models : [ ] } ,
1026+ } ,
1027+ ] ) (
1028+ "does not alias-expand a custom model named 5.4 when the requested instance is $state" ,
1029+ ( { requested } ) => {
1030+ const disabledCodex = ProviderInstanceId . make ( "codex" ) ;
1031+ const { state, traits } = composerFor ( {
1032+ providers : [
1033+ { ...provider ( { provider : codex , instanceId : disabledCodex } ) , ...requested } ,
1034+ {
1035+ ...provider ( { provider : codex , instanceId : "codex_team" } ) ,
1036+ models : [ reasoningModel ( "gpt-5.4" , "reasoningEffort" ) ] ,
1037+ } ,
1038+ ] ,
1039+ customModels : { [ disabledCodex ] : [ "5.4" ] } ,
1040+ threadModelSelection : createModelSelection ( disabledCodex , "5.4" , [
1041+ { id : "reasoningEffort" , value : "xhigh" } ,
1042+ ] ) ,
1043+ } ) ;
1044+
1045+ expect ( state . selectedModel ) . toBe ( "gpt-5.4" ) ;
1046+ expect ( traits . modelOptionsForDispatch ) . toBeUndefined ( ) ;
1047+ } ,
1048+ ) ;
1049+
1050+ it ( "does not alias-expand the fallback instance's custom model" , ( ) => {
1051+ const { state, traits } = composerFor ( {
1052+ providers : [
1053+ { ...provider ( { provider : codex , instanceId : "codex" } ) , enabled : false } ,
1054+ {
1055+ ...provider ( { provider : codex , instanceId : "codex_team" } ) ,
1056+ models : [ reasoningModel ( "5.4" , "reasoningEffort" , { isCustom : true } ) ] ,
1057+ } ,
1058+ ] ,
1059+ customModels : { codex_team : [ "5.4" ] } ,
1060+ threadModelSelection : createModelSelection ( ProviderInstanceId . make ( "codex" ) , "gpt-5.4" , [
1061+ { id : "reasoningEffort" , value : "xhigh" } ,
1062+ ] ) ,
1063+ } ) ;
1064+
1065+ expect ( state . selectedModel ) . toBe ( "5.4" ) ;
1066+ expect ( traits . modelOptionsForDispatch ) . toBeUndefined ( ) ;
1067+ } ) ;
1068+
1069+ it ( "does not carry options through an alias that names another model per instance" , ( ) => {
1070+ // "antigravity-default" is each Antigravity instance's current model.
1071+ const antigravity = ProviderDriverKind . make ( "antigravity" ) ;
1072+ const disabledAntigravity = ProviderInstanceId . make ( "antigravity" ) ;
1073+ const current = { isDefault : true , aliases : [ ANTIGRAVITY_DEFAULT_MODEL ] } ;
1074+ const { state, traits } = composerFor ( {
1075+ providers : [
1076+ {
1077+ ...provider ( { provider : antigravity , instanceId : disabledAntigravity } ) ,
1078+ enabled : false ,
1079+ models : [ reasoningModel ( "gemini-3-pro" , "thinking" , current ) ] ,
1080+ } ,
1081+ {
1082+ ...provider ( { provider : antigravity , instanceId : "antigravity_work" } ) ,
1083+ models : [ reasoningModel ( "claude-sonnet-4-6" , "thinking" , current ) ] ,
1084+ } ,
1085+ ] ,
1086+ threadModelSelection : createModelSelection ( disabledAntigravity , ANTIGRAVITY_DEFAULT_MODEL , [
1087+ { id : "thinking" , value : "high" } ,
1088+ ] ) ,
1089+ } ) ;
1090+
1091+ expect ( state . selectedModel ) . toBe ( "claude-sonnet-4-6" ) ;
1092+ expect ( traits . modelOptionsForDispatch ) . toBeUndefined ( ) ;
1093+ } ) ;
1094+ } ) ;
1095+
9571096 it ( "does not carry options to another driver" , ( ) => {
9581097 const codexOnly : ReadonlyArray < ServerProvider > = [
9591098 {
0 commit comments