There is no universal filter... in the system tree view, select the custom drop down and click add. The add the last communication time to be 30 days.
Then update all your queries with the same filter.
There is a server task which you can run after every synchronization which will remove the inactive Agents. Copy and edit to what ever parameters you like, then set it to run 2-5 minutes after AD or LDAP synch.