Is it illegal to apply for a patent under a pseudonym?

No

First of all, agencies are generally not responsible for the novelty of patents, and the state does not conduct substantive examination of utility model patents, so your patent may be invalid.

Second, the infringer is a third person, and it is unreasonable for you to ask the agency to be responsible for the consequences of the infringement.

Third, a supplementary agreement can be signed, and the agency can be required to provide free legal aid after the infringement occurs. When the agency promises this service, it may ask you to raise the price of the patent application agency.