Engagement is a critical motivational factor that has broad effects on learning, productivity, performance, and even satis-faction and happiness. However, it can also be impacted by a myriad of factors which have made it difficult to model anddesign interventions. Here we address this problem by developing an integrated metacognitive framework for understand-ing task engagement. We treat engagement as resulting from a unified metacognitive decision process where the gradientof engagement results from a common priority calculation. Priority signals are computed relative to a set of availabletasks and updated across time and environmental changes. We propose a metacognitive controller makes decisions aboutboth task switching (when to quit, next task) and cognitive resourcing (working memory, attention, etc) using the gradedpriority signals. By simultaneously choosing the task and allocating resources using the same graded signals, we capturethe complex dependencies of engagement with task errors, performance, and time allocation.