The `loadAgents()` function is getting called twice. This was causing the "Unable to connect..." message to appear *after* the page already loaded.