We discuss the evolution of stars through the asymptotic giant branch, focusing on the physical mechanisms potentially able to alter the surface chemical composition and on how changes in the chemistry of the external regions affect the physical properties of the star and the duration of this evolutionary phase. We focus on the differences between the evolution of low-mass stars, driven by the growth of the core mass and by the surface carbon enrichment, and that of their higher mass counterparts, which experience hot bottom burning. In the latter sources, the variation of the surface chemical composition reflects the equilibria of the proton capture nucleosynthesis experienced at the base of the convective envelope. The pollution expected from this class of stars is discussed, outlining the role of mass and metallicity on the chemical composition of the ejecta. To this aim, we considered evolutionary models of 0.7–8 M⊙ stars in a wide range of metallicities, extending from the ultra-metal-poor domain to super-solar chemistries.