As noted in this comment, %paste was corrected to store its contents, and not its command equivalent itself, in history. But cpaste still does the latter:
Python 3.10.8 (main, Oct 13 2022, 10:17:43) [Clang 14.0.0 (clang-1400.0.29.102)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.6.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: %cpaste -q
print('test')
print('Will this be stored?')
--
test
Will this be stored?
In [2]: In[1]
Out[2]: "get_ipython().run_line_magic('cpaste', '-q')"