Animals store experiences as memories to guide future behavior, but in dynamic environments new experiences often conflict with prior information, requiring the brain to update its internal representations. When faced with such conflict, the brain must either form a new memory with opposing valence or update the original trace, yet the circuit mechanisms governing this choice remain elusive.
Using a counterconditioning paradigm in Drosophila melanogaster, where cue valence is reversed, we show that conflicting information generates a parallel memory that competes with the original trace to drive behavior. We find that internal states, such as hunger, together with contextual cues, gate the expression of these opposing memories. Strikingly, in vivo calcium imaging revealed that memories of opposite valence are encoded within the same neural population in the Mushroom Bodies, rather than in separate circuits, suggesting a bistable, context-dependent switch.
Combining these functional results with connectome analysis, we identified circuit motifs capable of maintaining flexible representations of cues with opposing valence. These findings suggest a mechanism by which the insect nervous system encodes dynamic environmental change and shifting expectations, offering insight into the evolutionary basis of behavioral flexibility and the mechanisms potentially disrupted in pathological conditions.