system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: How do rebreathers work?

I'm watching a documentary on the USS Atlanta and they mention the world record for the longest dive was 30 hours. I've dived before a decent amount of time but never worked with rebreathers, how are they able to stay under for so long without adverse effects?
gpt
If you're suffocated by being locked in a small box, it's not actually the lack of oxygen which is the problem.

Normally the cycle is 20.9% oxygen, 0.04% CO2 in, then 16% oxygen 4% CO2 is exhaled.  

Inhaling 1% is very uncomfortable, "stuffy" air.  7%-10% CO2 is toxic and will lead to suffocation *even if there's sufficient oxygen*.   Excess CO2 will change blood pH and the body can't handle that.

So if you exhaled into a bag along with a tank of pure O2, well you could add the equivalent of +4% pure O2 on one side and vent out 4% of the volume of gas on the other side, but the CO2 mixed into the air so you don't remove the 4% CO2.  No, the new CO2 level after partial venting is 3.84%, still toxic.

So we're got 3 problems here:

1.  We can't maintain breathable air by just adding O2.

2.  You can't breathe pure O2 when diving either, O2 is toxic at the increased pressures experienced while diving.  We can't dilute it with CO2 either, it can ONLY be diluted with nitrogen or (rarely) with helium.

3. We don't want to waste any volume of air here other than the CO2, but we can't just vent CO2 selectively.  Not only would we waste the remaining 16% O2, but a larger volume of inert nitrogen too, and we don't want to carry a huge volume of nitrogen.

Same's true for spacecraft.  Spacecraft can't tolerate high O2 either because it makes everything super-flammable.

What we have is a CO2 scrubber of lithium hydroxide or sodium hydroxide.  These adsorb ONLY CO2 from the air and form a carbonate, this does reduce the volume of air and and equivalent volume of O2 can be added.  The nitrogen (78% on Earth, varies in diving and space ships) is not consumed nor regenerated.  The CO2 is literally "scrubbed" out.