Perovskite solar cells (PSCs) have reached power conversion efficiencies of more than 26%, but their lack of stability in real-world cycling conditions is still the main thing holding back their commercial use. In this study, we show how to use photoswitchable azobenzene-based molecular additives to change the grain boundaries. These additives respond to light cycling in a way that reduces stress and stops degradation pathways. The additive 4-(phenylazo)benzoic acid (CaAbz) is added to triple-cation Cs0.05MA0.05FA0.9PbI3 perovskite films. It sticks to the grain boundaries through carboxylic acid groups and stays flexible so that E⇄Z photoisomerization can happen again and again. When light cycles with UV in it, the isomerisation dynamically gets rid of intergranular strain, which lowers the chance of lattice bond breakage and defect buildup. The optimised devices have a power conversion efficiency of 26.8% (certified 26.4%) and keep their performance at 96.3% after 2,000 hours of light cycling (12 hours of light and 12 hours of dark, 65°C, and UV-containing light) and 97.8% after 500 thermal cycles (-40°C to 85°C). Comparative analysis indicates that singleanchoring-group molecules surpass non-anchoring or double-anchoring counterparts owing to an optimal equilibrium between passivation and photoswitchability. Grazing-incidence wide-angle X-ray scattering and X-ray photoelectron spectroscopy show that the formation of PbI2 and the transformation of δ-phase are both stopped. This study demonstrates that photoswitchable grain boundary engineering is a feasible approach to developing commercially viable perovskite photovoltaics that can endure real-world operational stressors.