Lee was - usually - a brilliant commander. His decision to attack without full comprehension of the Union positions and strength on Day Two was aggressively inadvisable. He wanted the "finishing blow" on the AotP and pressed when he shouldn't have. He had the Union forces contained and cornered and, as Longstreet asserted, he should've waited them out and turned his attentions to completely surrounding them and severing their supply lines. If nothing else, he should've waited for better scouting and intelligence (and Stuart) instead of pressing.
His Day Three assault was just out-of-character foolishness on Lee's part. If Day Two's failures hadn't shown him that, I'm not sure what would. He had Stuart by then and really should've utilized the cavalry better to his advantage. If nothing else, he should've given better consideration to a strategic withdrawal from the area to force Meade to surrender the advantageous position.
It's easy to make an explanation after-the-fact for bad decisions. He had THE CITY. He had the Union in a contained position. He might not have liked his chances for foraging, but they were still better than Meade's abilities to replenish his forces while they occupied the higher ground.
In short, Longstreet was right. This was just a rare blunder on Lee's part.