It would probably be useful if a little more background information could be given in this thread.
“AGC compensation” is commonly found in voice recorders, camcorders and such like as an attempt to automatically set the input gain for audio recording. Most commonly this is implemented as a compressor with slow attack/release parameters (similar to the Audacity compressor), but really this should be implemented in hardware in the input stage of the microphone pre-amp.
The effect/process being described in this topic is significantly different from that common case, in that it is being implemented in software post recording, and it is has extremely short attack/release times. The described code behaves more like a gate which has an inverted rms signal fed into the side chain.
The average of two rms signals is not the same as the root of averaging the squares of all samples, but I don’t want to break the flow of this topic so I’ll start a new topic here: Stereo tracks in Nyquist