Agent service discovery

—
I'm going to chime in:

using `defer func() { //  ... }()` to form a closure and doing something with a variable that gets modified after the `defer` is declared (as in your example) is something I've seen regularly enough to not find it surprising.