code: func (m *AgentPool) removeDisconnected() {
  	for agentKey, agentSlice := range m.agents {
  		// Filter and close all disconnected agents.
  		validAgents := filterAndClose(agentSlice, func(agent *Agent) bool {
  			if agent.getState() == agentStateDisconnected {
  				return true
  			}
  			return false
  		})
  
  		// Update (or delete) agent key with filter applied.
  		if len(validAgents) > 0 {
  			m.agents[agentKey] = validAgents
  		} else {
  			delete(m.agents, agentKey)
  		}
  	}
  }
docs: // removeDisconnected removes disconnected agents from the list of agents.
  // This function should be called under a lock.