The "Conditions" as described on the "Samples" looks promising - looks like you can search for a pattern which is within X lines of another pattern. That's useful for finding lines used only in certain contexts. AFAIK, there's no way to do that with ag.