Both in vivo neuropharmacology and optogenetic stimulation can be used to decode neural circuitry, and can provide therapeutic strategies for brain disorders. However, current neuronal interfaces hinder long-term studies in awake and freely behaving animals, as they are limited in their ability to provide simultaneous and prolonged delivery of multiple drugs, are often bulky and lack multifunctionality, and employ custom control systems with insufficiently versatile selectivity for output mode, animal selection and target brain circuits. Here, we describe smartphone-controlled, minimally invasive, soft optofluidic probes with replaceable plug-like drug cartridges for chronic in vivo pharmacology and optogenetics with selective manipulation of brain circuits. We demonstrate the use of the probes for the control of the locomotor activity of mice for over four weeks via programmable wireless drug delivery and photostimulation. Owing to their ability to deliver both drugs and photopharmacology into the brain repeatedly over long time periods, the probes may contribute to uncovering the basis of neuropsychiatric diseases.