A robin pecks at your window primarily because it sees its own reflection and mistakes it for a rival bird invading its territory. This behavior is especially common during the breeding season when male robins are highly territorial and feel the need to defend their nesting area from perceived intruders. The robin attacks the reflection repeatedly, trying to drive away the "intruder" it sees in the glass. This pecking is not due to curiosity or hunger but territorial aggression, driven by instinct. It usually happens in the spring or early summer during the robin's breeding period. The behavior can persist until the breeding season ends, or it can be mitigated by blocking or altering the reflection on the window. For example, placing paper, taping, painting, or using decals on the outside of the window to reduce or eliminate the reflective surface can stop the robin from attacking the window. Once the bird no longer sees its reflection, it will typically stop this behavior.