Cognitive flexibility - the mental agility to adapt strategies when circumstances change - may depend more heavily on a specific brainstem-to-cortex pathway than previously understood. This neural circuit could represent a key target for enhancing decision-making and attention in aging adults. Researchers used advanced calcium imaging and selective neural silencing in mice performing attention-switching tasks to map how the locus coeruleus brainstem region communicates with the medial prefrontal cortex. When scientists chemogenetically disabled either the brainstem neurons or their projections to the prefrontal cortex, mice lost their ability to flexibly switch attention between different sensory cues during complex behavioral tasks. The impairment was severe and specific to cognitive switching rather than basic sensory processing. Brain imaging revealed that suppressing brainstem input paradoxically increased prefrontal cortex activity but made individual neurons less selective and disrupted coordinated population dynamics essential for encoding rule changes. This suggests the locus coeruleus acts as a critical gatekeeper, fine-tuning prefrontal networks to maintain optimal signal-to-noise ratios during cognitive transitions. The findings illuminate why age-related decline in locus coeruleus function correlates with reduced mental flexibility in humans. Unlike previous pharmacological approaches that broadly affected multiple brain regions, this work pinpoints a specific circuit whose targeted modulation could potentially preserve or restore cognitive agility. The research provides mechanistic insight into how brainstem arousal systems sculpt higher-order thinking, suggesting that maintaining locus coeruleus health through lifestyle interventions or targeted therapies may be crucial for preserving executive function throughout the lifespan.