It's sadly not the longest, but this April Fools style TAS of Rampage is amusing. Every time you use a continue, the game advances slightly no matter where you are, so if you just continue for 7 hours, the game beats itself with no meaningful gameplay.
http://tasvideos.org/forum/viewtopic.php?t=5400&highlight=
If every speedrun category had a TAS, the longest TAS would be the same as the longest speedrun - Baten Kaitos 100%.
https://www.reddit.com/r/speedrun/comments/3s2rk5/wr_baten_kaitos_100_in_3450312/
Because to get 100% in Baten Kaitos you have to wait for the Shampoo to evolve, which takes 2 weeks in real time, it is impossible to complete the run any faster than that. (Time losses are to menuing during the 2 weeks, getting the shampoo from the start of the run, and going from the shampoo evolving to beating the final boss)
AFAIK all the real time speedruns that are theoretically longer but have never been finished single segment are so long because of huge amounts of RNG, so TASes of them would probably be faster than a Baten Kaitos 100% TAS.
Another good candidate for an absurdly long TAS would be Super Mario 64 "120 stars, minimum A presses", as many A press minimizing strategies require you to perform repetitive actions for hours at a time (for speed to build up, to overflow/underflow water level, cloning over and over, etc).