IRS records should be kept for a minimum of 3 years but keeping the IRS records for as long as 7 years is much better.
You certainly need to keep IRS records for 7 years if you file a claim for a loss from worthless securities or bad debt deduction.
I always just file away all my IRS records and any other important papers and documents relating to the IRS for at least 7 years just to be safe and have them.
After 7 years I can then destroy those records if no longer needed.