When a behavior repeatedly fails to achieve its goal,animals often give up and become passive, whichcan be strategic for preserving energy or regroupingbetween attempts. It is unknown how the brain identifiesbehavioral failures and mediates this behavioral-state switch. In larval zebrafish swimming invirtual reality, visual feedback can be withheld sothat swim attempts fail to trigger expected visualflow. After tens of seconds of such motor futility,animals became passive for similar durations.Whole-brain calcium imaging revealed noradrenergicneurons that responded specifically to failedswim attempts and radial astrocytes whose calciumlevels accumulated with increasing numbers of failedattempts. Using cell ablation and optogenetic or chemogeneticactivation, we found that noradrenergicneurons progressively activated brainstem radial astrocytes,which then suppressed swimming. Thus,radial astrocytes perform a computation critical forbehavior: they accumulate evidence that current actionsare ineffective and consequently drive changesin behavioral states.