Formal methods for general-purpose AI agents