@@ -874,6 +874,52 @@ describe("ProviderSettingsManager", () => {
874874 expect ( exported . apiConfigs . retired . modelMaxTokens ) . toBe ( 4096 )
875875 expect ( exported . apiConfigs . retired . modelMaxThinkingTokens ) . toBe ( 2048 )
876876 } )
877+
878+ it ( "should preserve modelMaxTokens for models that support a configurable max output (e.g. GLM)" , async ( ) => {
879+ const existingConfig : ProviderProfiles = {
880+ currentApiConfigName : "glm" ,
881+ apiConfigs : {
882+ glm : {
883+ id : "glm-id" ,
884+ apiProvider : "zai" ,
885+ apiModelId : "glm-5.1" ,
886+ modelMaxTokens : 8192 ,
887+ modelMaxThinkingTokens : 2048 ,
888+ } ,
889+ } ,
890+ }
891+
892+ mockSecrets . get . mockResolvedValue ( JSON . stringify ( existingConfig ) )
893+
894+ const exported = await providerSettingsManager . export ( )
895+
896+ // GLM exposes a configurable max output (supportsMaxTokens) but no reasoning budget,
897+ // so modelMaxTokens must survive the export while modelMaxThinkingTokens is dropped.
898+ expect ( exported . apiConfigs . glm . modelMaxTokens ) . toBe ( 8192 )
899+ expect ( exported . apiConfigs . glm . modelMaxThinkingTokens ) . toBeUndefined ( )
900+ } )
901+
902+ it ( "should strip both token fields for models that support neither reasoning budgets nor a configurable max" , async ( ) => {
903+ const existingConfig : ProviderProfiles = {
904+ currentApiConfigName : "anthropic" ,
905+ apiConfigs : {
906+ anthropic : {
907+ id : "anthropic-id" ,
908+ apiProvider : "anthropic" ,
909+ apiModelId : "claude-3-5-haiku-20241022" ,
910+ modelMaxTokens : 8192 ,
911+ modelMaxThinkingTokens : 2048 ,
912+ } ,
913+ } ,
914+ }
915+
916+ mockSecrets . get . mockResolvedValue ( JSON . stringify ( existingConfig ) )
917+
918+ const exported = await providerSettingsManager . export ( )
919+
920+ expect ( exported . apiConfigs . anthropic . modelMaxTokens ) . toBeUndefined ( )
921+ expect ( exported . apiConfigs . anthropic . modelMaxThinkingTokens ) . toBeUndefined ( )
922+ } )
877923 } )
878924
879925 describe ( "ResetAllConfigs" , ( ) => {
0 commit comments