The post of legal advisor of the ministry is created pursuants to Article 145 (2) of the Federal Constitution which states:-
Article 145.(1) ...
(2) It shall be the duty of the Attorney General to advise the Yang di-Pertuan Agong or the Cabinet or any Minister upon such legal matters, and to perform such other duties of a legal character, as may from time to time be referred or assigned to him by the Yang di-Pertuan Agong or the Cabinet, and to discharge the functions conferred on him by or under this Constitution or any other written law.”.
The legal advisor serving in the ministry is a special representative of the Attorney General whose general function is to advise the ministry on legal matters. Therefore, the presence of the legal advisor of the ministry is to perform the duties under the Constitution as expressly stated under Article 145 (2) of the Federal Constitution.