Research indicates that impasse-driven learning can have important benefits for improving student mastery of material. When students recognize gaps in their understanding of a concept, attempt self-explanations to resolve the impasses, and then receive further assistance from an instructor, the concept is more likely to be learned than without the impasse or self-explanation. This paper proposes that AI programming assignments be designed to encourage useful impasses and self-explanation, by (1) guiding student attention levels to increase students' scrutiny of areas important to pedagogical goals and 2) prompting fruitful expectation failures. It presents general guidelines for managing student attention levels when designing programming assignments, and describes how this strategy can be operationalized through the use of code frameworks. It illustrates the approach with concrete examples from sample AI assignments.