> Manduca sexta caterpillars received an electrical shock associatively paired with a specific odor in order to create a conditioned odor aversion, and were assayed for learning in a Y choice apparatus as larvae and again as adult moths. We show that larvae learned to avoid the training odor, and that this aversion was still present in the adults.
https://journals.plos.org/plosone/article?id=10.1371/journal...
This is why certain memories can be retained and certain ones can't.
EDIT:
"Textbooks will commonly talk about the insect dissolving into a kind of “soup”, but that’s not entirely accurate. Some organs stay intact. Others, like muscles, break down into clumps of cells that can be re-used, like a Lego sculpture decomposing into bricks. And some cells create imaginal discs—structures that produce adult body parts. There’s a pair for the antennae, a pair for the eyes, one for each leg and wing, and so on. So if the pupa contains a soup, it’s an organised broth full of chunky bits."
https://www.nationalgeographic.com/science/article/3-d-scans...