Effectively you have to use tmux or screen as a condom at that point - programs that refuse to use terminfo/termcap will spew whatever xterm-like escapes they hardcode at tmux/screen, which then uses terminfo/termcap to translate to your actual terminal.