I'm not a teacher, but I think I know this one.
(1) Yesterday I thought that next time I would stay there as long as possible.
is the one you do applying the grammar rules strictly,
(2) Yesterday I thought that next time I will stay there as long as I can.
does not change the verb because your resolution is still valid, you still think that you will stay there if the occasion arises.
By the same token, if you have changed your mind, you would probably prefer (1).
I'm interested to hear what the teachers say to this.
Student or Learner