code: def replace_agent(self, agent, pool_id, agent_id):
          
          route_values = {}
          if pool_id is not None:
              route_values['poolId'] = self._serialize.url('pool_id', pool_id, 'int')
          if agent_id is not None:
              route_values['agentId'] = self._serialize.url('agent_id', agent_id, 'int')
          content = self._serialize.body(agent, 'TaskAgent')
          response = self._send(http_method='PUT',
                                location_id='e298ef32-5878-4cab-993c-043836571f42',
                                version='5.1-preview.1',
                                route_values=route_values,
                                content=content)
          return self._deserialize('TaskAgent', response)
docs: ReplaceAgent.
          [Preview API] Replace an agent.  You probably don't want to call this endpoint directly. Instead, [use the agent configuration script](https://docs.microsoft.com/azure/devops/pipelines/agents/agents) to remove and reconfigure an agent from your organization.
          :param :class:`<TaskAgent> <azure.devops.v5_1.task_agent.models.TaskAgent>` agent: Updated details about the replacing agent
          :param int pool_id: The agent pool to use
          :param int agent_id: The agent to replace
          :rtype: :class:`<TaskAgent> <azure.devops.v5_1.task-agent.models.TaskAgent>`