code: def agent_run(args):
      
      run = wandb.wandb_run.Run.from_environment_or_defaults()
      run.enable_logging()
  
      api = wandb.apis.InternalApi()
      api.set_current_run_id(run.id)
  
      # TODO: better failure handling
      root = api.git.root
      # handle non-git directories
      if not root:
          root = os.path.abspath(os.getcwd())
          host = socket.gethostname()
          remote_url = 'file://{}{}'.format(host, root)
  
      run.save(program=args['program'], api=api)
      env = dict(os.environ)
      run.set_environment(env)
  
      try:
          rm = wandb.run_manager.RunManager(api, run)
      except wandb.run_manager.Error:
          exc_type, exc_value, exc_traceback = sys.exc_info()
          wandb.termerror('An Exception was raised during setup, see %s for full traceback.' %
                          util.get_log_file_path())
          wandb.termerror(exc_value)
          if 'permission' in str(exc_value):
              wandb.termerror(
                  'Are you sure you provided the correct API key to "wandb login"?')
          lines = traceback.format_exception(
              exc_type, exc_value, exc_traceback)
          logging.error('\n'.join(lines))
      else:
          rm.run_user_process(args['program'], args['args'], env)
docs: A version of `wandb run` that the agent uses to run things.