the solution is actually really simple. Don’t write depth on things that you want to be excluded. AO pass works on the depth buffer, so if an object is not written into it - it will not participate in the pass.
I don’t think it’s quite so simple. If you don’t render an object to the depth buffer then the SAO results of the background object will just render on top of it. Granted that might be good enough in some cases. Instead you probably want to draw the objects you want to exclude after SAO has been applied to the rest of the scene but I’m not sure how easy that is to do here.