We propose an approach to online model adaptation and control in thechallenging case of hybrid and discontinuous dynamics where actions may lead todifficult-to-escape "trap" states, under a given controller. We first learndynamics for a system without traps from a randomly collected training set(since we do not know what traps will be encountered online). These "nominal"dynamics allow us to perform tasks in scenarios where the dynamics matches thetraining data, but when unexpected traps arise in execution, we must find a wayto adapt our dynamics and control strategy and continue attempting the task.Our approach, Trap-Aware Model Predictive Control (TAMPC), is a two-levelhierarchical control algorithm that reasons about traps and non-nominaldynamics to decide between goal-seeking and recovery policies. An importantrequirement of our method is the ability to recognize nominal dynamics evenwhen we encounter data that is out-of-distribution w.r.t the training data. Weachieve this by learning a representation for dynamics that exploits invariancein the nominal environment, thus allowing better generalization. We evaluateour method on simulated planar pushing and peg-in-hole as well as real robotpeg-in-hole problems against adaptive control, reinforcement learning,trap-handling baselines, where traps arise due to unexpected obstacles that weonly observe through contact. Our results show that our method outperforms thebaselines on difficult tasks, and is comparable to prior trap-handling methodson easier tasks.