The earliest way I got this working in my game was to have a list recorded of the direction, X and Y and any initial propulsion physics (like jumping, wind etc) of the main character. Every key event, such as running outside of a radius between the 2, jumping, fighting etc, basically anything more than standing nearby would start the recording sequence and the AI player would follow. This works especially well if you're using 2 PMO objects to handle them both. Then have the AI look at the position and move at the same speed etc.
It's kinda primitive really and only really works if both the player and AI have the same physics properties.
So it'd be good to use either the List object with string parsers or an array.
But that is just relentless following and doesn't take into account independent path finding, say if the AI character misses a platform and has to work its way back up. That's another load of coding.