You are not allowed to apply for a patent while engaged in patent agency business and within one year after leaving the patent agency business.
If you want to apply, you have to leave the agency business. You can resign for one year before applying for a patent.
Your agent qualification certificate will be canceled only if you have not engaged in patent agency business or patent management work for five years. (In reality, apart from punishment, your qualification certificate will rarely be revoked, and no one will take the initiative to check)
After applying for a patent, you can reapply for a practicing certificate without having to retake the agent exam.