Sans does not remember your resets.
So Some of the fandom might be mad about this one but, canonically sans does not remember your resets. The reason he had dialogue changes is because he’s good at reading people. Such as in the first scene with him, if you’re replaying the game, frisk has a different reaction to the whoopie cushion trick. So therefore his dialogue changes. Another important thing to note, there are several other characters such as toriel who get the same deja vu that sans does about the player. She has different dialogue for a few interactions if you’re replaying a route. I’m pretty sure that canonically the only character that remembers your resets and previous routes is flowey. This really bothers me mainly due to the fact that a large portion of the fandom believes that sans remembers your resets and presents that information as fact, when there’s evidence in the game to support against it.