In addition to sufficient planning and rehearsal, IMO any group should have a core of riffs and songs learned well enough that they could be played at a moment's notice.
Preparing for the unexpected...that group you see 'jamming' may have it all worked out in advance...