How to prevent small birds from getting trapped inside open double-hung windows?
The standard approach to sealing the top of the lower sash raised for the AC is a foam strip placed between the outward facing uper edge of the inner sash and the outer glass pane.



This gap is on the inside of the house. 

The birds you mention must be getting in through the lower gap between the lower rail of the upper sash and the glass pane on the inside sash.  There is no reason you could not use the same type of foam insulator on the outside (assuming you can safely reach the window).  While this is not a hard barrier that will prevent a forceful assault by a determined attack bird, it probably will be enough to discourage the accidental intruder.

The foam will likely deteriorate much more quickly outdoors, but should last a  season.