The predictive processing framework posits that one of the main functions of the brain is to anticipate the incoming information. Internal models facilitate interactions with the world by predicting future states against which actual evidence is compared. The difference between predicted and actual states, the prediction error (PE), signals novel information. However, how PE affects cognitive processing downstream is not fully understood: one such aspect pertains to how PE influences episodic memories, and whether those effect on memory differ across the lifespan. We examine the relationship between PE and episodic memory in children, young and older adults. We use a novel paradigm whereby rich visual narratives are used to build action schemas that enable probing different mnemonic aspects. To create different levels of PE, we manipulate the story endings to be either expected, neutral or unexpected with respect to the unfolded action. We show that (i) expected endings are better encoded than neutral endings and (ii) unexpected endings improve the encoding of mismatching events and other aspects of the narrative. These effects are differentially modulated across the lifespan with PE-driven encoding being more prominent in children and young adults and with schema integration playing a larger role on memory encoding in older adults. These results highlight the role of predictions by enriching past experiences and informing future anticipations.This article is part of the theme issue 'Elements of episodic memory: lessons from 40 years of research'.