Officials reach agreement to spare Dakota the dog