Unless you've seen the code like a few of us.
The AI has a few conditions that increase or decrease the chance that it will use an ability. For instance it might not consider a perm to be a high enough priority at the time, given what's on the field and its current HP. However, all its conditions aside, it actually has a little randomness programmed into it. Every time it's prompted to make a decision, there's a small chance that it will simply cancel the decision. This is the reason it didn't destroy your Sundial, even though it might've saved its life.