The answer in my mind is simple and straight forward. Leave the minimum amount of gear required to make a good/acceptable anchor everytime. What that looks like will depend on the situation at hand.
In some cases this will be two carabiners and a sling, in others it will be three big cams and a cordelette. If you're lucky then it might be nothing due to a convenient string of rappel stations. If you're really unlucky you have to improvise an anchor out of materials on hand, and pray like hell.
If you're really worried about losing a couple of cams because they're expensive to replace, remember that just because you retreat today it doesn't mean you can't come back. I've had to retreat off of a route before due to poor planning, inexperience, youthful arrogance, and a rapidly descending sun. We left a few cams and a fixed rope on the route. I couldn't afford to lose that gear so you bet your butt we were at the base of the route at the crack of dawn the next day. It took us most of the day but we recovered all the gear.
The moral of the story is:
Use what you have to in order to retreat safely. Then come back and recover your gear as soon as possible.