Fix infinite loop in freeform AI module