code: def register_agent(self, host, sweep_id=None, project_name=None):
          
          mutation = gql('''
          mutation CreateAgent(
              $host: String!
              $projectName: String!,
              $entityName: String!,
              $sweep: String!
          ) {
              createAgent(input: {
                  host: $host,
                  projectName: $projectName,
                  entityName: $entityName,
                  sweep: $sweep,
              }) {
                  agent {
                      id
                  }
              }
          }
          ''')
          if project_name is None:
              project_name = self.settings('project')
  
          # don't retry on validation errors
          def no_retry_400(e):
              if not isinstance(e, requests.HTTPError):
                  return True
              if e.response.status_code != 400:
                  return True
              body = json.loads(e.response.content)
              raise UsageError(body['errors'][0]['message'])
  
          response = self.gql(mutation, variable_values={
              'host': host,
              'entityName': self.settings("entity"),
              'projectName': project_name,
              'sweep': sweep_id}, check_retry_fn=no_retry_400)
          return response['createAgent']['agent']
docs: Register a new agent
  
          Args:
              host (str): hostname
              persistent (bool): long running or oneoff
              sweep (str): sweep id
              project_name: (str): model that contains sweep