A really good AGC circuit is much more tricky than most people think because they (AGC circuits, not most people) are stupid. They can't tell the difference between a loud clang and a loud vowel, and they can't interpret either and make a judgement about whether they represent something worth correcting because they are the first of many such noises, or something to just clip and let go because the next sounds will be quiet again. Your brain does this in microseconds. Chips can't.
Adafruit has an AGC mic preamp module based on a Maxim mic preamp chip, and it is the easiest way I've ever seen to evaluate a simple AGC to see if it does more good than harm in your application. Next is a more complex AGC based on the RMS value of the audio rather than the peak value, but that is a very different discussion.
ak