The Drosophila mushroom body exhibits dopamine (DA) dependent synaptic plasticity that underlies the acquisition and retrieval of associative memories. Classic studies have recorded DA activity in this system and identified signals related to external reinforcement such as reward and punishment. However, recent studies have found that other factors including locomotion, novelty, reward expectation, and internal state also modulate DA neurons. This heterogeneous activity is at odds with typical modeling approaches in which DA neurons are assumed to encode a global, scalar error signal. How can DA signals support appropriate synaptic plasticity in the presence of this heterogeneity? We develop a modeling approach that infers a pattern of DA activity that is sufficient to solve a defined set of behavioral tasks, given architectural constraints informed by knowledge of mushroom body circuitry. Model DA neurons exhibit diverse tuning to task parameters while nonetheless producing coherent learned behaviors. Our results provide a mechanistic framework that accounts for the heterogeneity of DA signals observed during learning and behavior.