All My Sins Remembered by Joe Haldeman

In a future where humanity has expanded across the stars, a man named Otto McGavin is recruited by the Confederación, an interstellar organization, to become a secret agent. Through advanced technology, Otto undergoes a series of personality overlays, allowing him to assume various identities and complete missions that challenge his moral compass. As he navigates the complexities of espionage, identity, and ethics, Otto grapples with the psychological toll of his assignments, questioning the true cost of his service and the essence of his own identity.