Implement support for auto-discovering services for passive agents.

Fixes #6002