The idea is that player first time trying to complete the level perform some actions, then presses a button, and next time his copy repeats actions that player did last tries.
If its like, limited to movement. You can make a 2D array of the movement direction (vector) and the time in delta (float) that the player holded that particular movement to save the actions, and then after the button, play that array on the AI.
I’d do the same, only with storing a sequence of input + duration sets rather than movement direction & time in delta.
Could be a bit simpler in practice - never tried it myself though.