  We study the redshift evolution of the baryon budget in a large set of galaxy
clusters from the {\it Magneticum} suite of SPH cosmological simulations. At
high redshifts, we obtain "closed box" systems independently by the mass of the
systems on radii greater than $3R_{500,\mathrm c}$, whereas at lower redshifts,
only the most massive halos could be considered as `"closed box". The baryon
fraction shows a general decrease with the redshift and, for less massive
objects, we observe a much more prominent decrease than for massive halos. The
gas depletion parameter $Y_{\rm gas}$ shows a steeper and highly scattered
radial distribution in the central regions of less massive halos with respect
to massive objects at all redshifts, while on larger radii the gas fraction
distributions are independent of the masses or the redshifts. The hot component
of the gas traces well the total amount of gas at low redshifts. At higher
redshifts, the cold component provides a not negligible contribution to the
total amount of baryon in our systems. Moreover, the behaviour of the baryonic,
entire gas, and hot gas phase depletion parameters as a function of radius,
mass, and redshift are described by some functional forms. The evolution of
metallicity and stellar mass in halos suggests that the early enrichment
process is dominant. We investigate correlations between the time evolution of
AGN feedback and the depletion parameters. We demonstrate that the energy
injected by the AGN activity shows a particularly strong positive correlation
with $Y_{\rm bar}$, $Y_{\rm cold}$,$Y_{\rm star}$ and a negative one with
$Y_{\rm hot}$, $Z_{\rm Tot}$. These trends are consistent with previous works,
meaning that our results, combined with findings derived from current and
future X-rays observations, represent possible proxies to test the AGN feedback
models used in different suites of numerical simulations.
