While leading the Dendarii Mercenaries on a hostage rescue mission, Miles Vorkosigan has a seizure — a recurring consequence of his death and resuscitation in Mirror Dance — which results in his accidentally severing the rescued hostage's legs with his plasma arc weapon. Terrified of the consequences if his boss, Simon Illyan, the head of Imperial Security, finds out, Miles falsifies his mission report. However, Illyan finds out anyway from spies planted among the Dendarii, and Miles is forced to accept a medical discharge. Miles enters a period of depression, isolating himself in the Vorkosigan mansion, which is deserted due to his parents' taking charge of the new colony on the planet Sergyar. His cousin Ivan Vorpatril is sent to check on him. He arrives with Captain Duv Galeni of Imperial Security, who encountered Miles during the events of Brothers in Arms. They plunge Miles into an ice bath and then bully him into breaking out of his funk. Ivan moves into Vorkosigan House to keep an eye on Miles. Miles goes to Emperor Gregor, to apologize formally for his failures as an ImpSec officer. Gregor then surprises him by inviting him to a meeting with a Komarran guest. After years of refusing to marry any of the tall, slim, eligible Barrayaran ladies paraded in front of him by Alys Vorpatril, Gregor unexpectedly falls in love with a short, voluptuous Komarran, Laisa Toscane, a wealthy heiress and member of a Komarran economic delegation. However, Duv Galeni also has designs on Laisa, being Komarran himself. When Illyan suffers a sudden, crippling mental impairment, Miles attempts to investigate, but he receives no cooperation from Lucas Haroche, ImpSec's acting chief, so he asks Gregor to assign an Imperial Auditor, a top-level troubleshooter with practically unlimited authority and answerable only to the Emperor. Gregor unexpectedly decides that it would save many steps by making Miles himself a temporary Auditor. There are several problems, including the fact that Miles himself would be a suspect in any crime against Illyan. Duv Galeni also falls under suspicion due to his Komarran background, and his tirade against the Vor class when he heard that Laisa had agreed to marry Gregor. Duv is also the son of Ser Galen, a Komarran terrorist who was responsible for several plots against Barrayar, including the attempt to replace Miles Vorkosigan with a clone in Brothers in Arms. Illyan's breakdown seems to be caused by the artificial memory device implanted in his head when he was a young lieutenant. This was a whim of the then Emperor Ezar, Gregor's grandfather, who set Illyan to keep an eye on Aral Vorkosigan. The device begins dumping random memories into Illyan's brain, causing him to lose track of reality. After a horrific time standing watch over Illyan in the hospital, trying to keep him sane with help from Ivan and Alys, while a surgeon prepares to remove the device, Miles sets out to discover what caused the breakdown. He recruits the arrogant, brilliant "Dr. Waddell", formerly Hugh Canaba, whom he extracted from a bio-engineering facility on Jackson's Whole in the story Labyrinth. Waddell analyzes the extracted device and announces that the breakdown was caused by a synthetic biological agent from Jackson's Whole. Alerted by a false record in the log of ImpSec's store room that seemed to show him entering on a previous occasion, Miles assigns Ivan to inventory the contents and quickly finds that the agent came from the stores, having been confiscated from Ser Galen's organization. Someone in ImpSec was responsible, and was trying to frame Miles. Duv Galeni is arrested, but Miles thinks that is also a frame-up. After Miles unravels the devious crime in remarkably quick time, his appointment is made permanent. This inevitably means giving up the leadership of his Dendarii Mercenaries, leaving his second in command, and sometime lover, Elli Quinn, to take over. Miles, as Gregor's "Second", conducts the formal betrothal ceremony with Laisa. Illyan and Alys, meanwhile, have become secret lovers, to Ivan's dismay. Duv Galeni, freed from the cells at ImpSec, announces his engagement to Delia Koudelka. Miles undergoes surgery to implant a device that can be used to induce mild seizures as a palliative measure, the underlying condition being incurable. This becomes important in the next novel, Komarr.