Have had that happens myself, I honestly have forgotten what I did to fix it. If I remember I'll let you know,think it was a matter of removing and re-positioning the bobby AI module else where on the 'barrel' section of the turret, maybe actually touching the weapons modules. Give it a try and see what happens.
Pretty sure you used to be able to put them anywhere on the weapons part of the turret but now if they aint touching the weapons blocks themselves they revert to ship. Not 100% on this as the solution I will admit, been a while since it did it to me.
Any way, wouldn't be StarMade if the AI actually worked without a hitch. :p