code: func (a *Agent) UpdateTaskStatus(ctx context.Context, taskID string, status *api.TaskStatus) error {
  	log.G(ctx).WithField("task.id", taskID).Debug("(*Agent).UpdateTaskStatus")
  	ctx, cancel := context.WithCancel(ctx)
  	defer cancel()
  
  	errs := make(chan error, 1)
  	if err := a.withSession(ctx, func(session *session) error {
  		go func() {
  			err := session.sendTaskStatus(ctx, taskID, status)
  			if err != nil {
  				if err == errTaskUnknown {
  					err = nil // dispatcher no longer cares about this task.
  				} else {
  					log.G(ctx).WithError(err).Error("closing session after fatal error")
  					session.sendError(err)
  				}
  			} else {
  				log.G(ctx).Debug("task status reported")
  			}
  
  			errs <- err
  		}()
  
  		return nil
  	}); err != nil {
  		return err
  	}
  
  	select {
  	case err := <-errs:
  		return err
  	case <-ctx.Done():
  		return ctx.Err()
  	}
  }
docs: // UpdateTaskStatus attempts to send a task status update over the current session,
  // blocking until the operation is completed.
  //
  // If an error is returned, the operation should be retried.