Thinking agents for zero-shot generalization to qualitatively novel tasks