Well... I tested it in a few simpler battles and It seems to work relatively well. As we all know, the AI's phalanxes won't hold picture-perfect formations with guard mode off, but contrary to my expectations, they seem to suffer a bit more than usual in forests and difficult terrain. After fiddling around with a few more custom battles... I tested it with the historical Battle of Ipsos, and I must say... What an absolute mess. A glorious, brutal, phalanx-heavy mess.
On the other hand, when there are only 2-3 phalanx units in an AI army, they seem to perform quite well... they still often lag behind the rest of the army since they can't march double-time while in phalanx formation, but they aren't doing any worse than before.
One thing I did notice is that it's much more dangerous than it was before to disengage a phalanx unit that has its pikes trained on your men. Before making this edit, one could rather quickly and painlessly run away from a phalanx unit... now it's a lot harder; I noticed that even the reasonably well armored and very reliable hoplites, having been fully engaged head-on with standard phalangitai, lost a little more than 1/4 of their number when disengaging (medium battle difficulty, 1 v 1 custom battle).
Would it be possible to alter the script to make the 'lesser' phalanxes keep guard mode on, but allow the standard and agema phalanxes to disengage it? This way the 'lesser' phalanxes might still be used more defensively by the AI (i.e. "just stand here and hold them off, you'll be fine"), but the better versions might still be able to pack some more punch.