When I try to run Sage 7.5.1 inside the shell mode of emacs, the prompt produces escape characters before and after it says "sage", on OS X 10.11.6. My guess is that terminfo is doing something wacky and not realizing it is running under emacs.
I'm installing the sage-shell-mode as a workaround, but my guess is that terminfo being funny will show up in some other unexpected places.
Sincerely,
Watson