Abstract To survive in dynamic environments, the nervous system must be able to generate flexible behavior — seamlessly weaving together past experience with the present context to achieve future goals. Our team of experts on the neural circuits of behavior will collaborate to reveal the neural mechanisms by which a mouse engages in specific processing of one sensory modality versus another based on task demands. We hypothesize that these types of context-dependent behaviors operate through a flexible coupling and decoupling of neural networks mediated by changes in neural dynamics based on gain modulation, similar to mechanisms that are engaged in brain state regulation. During the waking state, arousal, attention, and task engagement constantly vary and are associated with ongoing and large changes in the activity of neuromodulatory (e.g., norepinephrine and acetylcholine) systems as well as intracortical feedback pathways whose role is to specifically modulate neural network interactions. Through identifiable and precise mechanisms, these pathways control the patterns of activity generated by the neocortex, flexibly increasing or decreasing the information flow between specific neuronal networks. By defining these precise mechanisms through a series of cutting-edge experiments, analysis and modelling, we will shed light onto how the nervous system generates context-dependent behavior. By understanding how the cortex flexibly reconfigures its functional interactions to produce contextually-appropriate behavior, and how arousal and engagement modulate this flexibility, we will provide insight into a broad range of human disorders, from those of attention and perception, to social interactions.