May not be the best help but try putting this in the cmd file as an AI code. Let's pretend that the state in question is 500, just hypothetically:
type = ChangeState
value = 500
triggerall = roundstate = 2 && AILevel
trigger1 = stateno = 500
This, theoretically, should make it so it only accesses that state, if it's already in that state. And since it can't be in that state as is, it'll never be able to loop it cause it can't enter that loop. So it'll never happen.
... I could be wrong, but it's a theory.