My talk will describe how we are building on foundational studies of neural mechanisms of perceptual decision-making to understand how those mechanisms can support cognitive flexibility. First, I will describe a general theoretical framework for optimal decision-making in dynamic environments, which emphasizes the flexible use of different computational primitives (e.g., working memory, history-dependent adjustments) in a manner that depends on the environmental statistics and task. Second, I will describe new findings relating some of these ideas to how the primate brain forms decisions, in particular how different adaptive mechanisms can be engaged and disengaged depending on the task conditions. I will conclude by speculating on principles that govern the use of these flexible processes in the brain, including trade-offs between computational costs and performance benefits.