Agent sniffing middleware