query filter for each agent type

This has the changes Mikko requested