Former CIA Director David Petraeus has agreed to plead guilty to mishandling classified information, with the retired four-star general admitting to giving eight "black books" full of such data to a military mistress who was writing his biography.