Reasoning Efficiently Through Adaptive Chain-of-Thought Compression: A Self-Optimizing Framework