Representation Learning for Agents in Non-Markovian Environments