Encapsulated engineered cells that produce a drug inside the body have great potential for treating various diseases, but safety concerns still exist. In this study, we develop a safety switch that links the production of the drug to the sensing of an intact encapsulation material.