The Enterprise arrives at Tyrus 7A to oversee a fledgling mining technology, a "particle fountain", engineered by Dr. Farallon. While on the planet, the crew observe the use of small machines called Exocomps that Dr. Farallon claims can analyze a problem, replicate the correct tool to repair it, and "learn" this for future situations. During a test, one Exocomp refuses to enter a tunnel; moments later a confined explosion occurs within the tunnel. Dr. Farallon, Lt. Commander Data, and Lt. La Forge investigate the Exocomp, finding several more new electronic pathways in its circuits than they expected. Dr. Farallon, having encountered this before, would normally erase the unit's memory, but Data suggests that the unit may have exhibited self-preservation behavior and wishes to examine it further. Data asserts that if this is true, the Exocomps should no longer be used on the particle fountain, but Dr. Farallon dismisses his claims, and says that any delay will ruin the years of work she has put into the project already.
Data tests the Exocomp aboard the Enterprise, instructing it to repair a malfunction in a Jeffries tubes, though having jury-rigged a false alarm that would alert the Exocomp to danger. To his disappointment, the Exocomp continues to repair the malfunction through the alarm. However, when Data investigates the unit, he finds that it has repaired not only the malfunction but his false alarm, having sensed it was not in any danger from the test. Data concludes the Exocomps possess self-preservation and are sentient.
While Picard and other Enterprise crew are visiting the fountain, a malfunction occurs, threatening to release massive doses of radiation. All but Picard and La Forge are beamed to the Enterprise before the radiation blocks any further attempts. Riker and Dr. Farallon arrange to have the Exocomps beamed into the facility to shield Picard and La Forge long enough to beam them out at the cost of destroying the Exocomps, but Data has locked out the transporter controllers, claiming the machines are sentient. After some negotiating, Data allows the Exocomps to be used but only if they chose to go. The Exocomps show their intent to proceed, and are beamed to the fountain. The units configure themselves that not only allow Picard and La Forge to be rescued, but for all but one of the Exocomps to return to the Enterprise, the last one sacrificing itself for this purpose.
As the damage to the fountain is repaired, Dr. Farallan admits she is still not sure if the Exocomps are sentient but promised not to abuse them again. Data explains to Picard that he had to stand up for the Exocomps, just as Picard had stood up for him when his own sentience was questioned. Picard acknowledges that Data's actions were probably the most human thing he has ever done.