code: func (a *Agent) withSession(ctx context.Context, fn func(session *session) error) error {
  	response := make(chan error, 1)
  	select {
  	case a.sessionq <- sessionOperation{
  		fn:       fn,
  		response: response,
  	}:
  		select {
  		case err := <-response:
  			return err
  		case <-a.closed:
  			return ErrClosed
  		case <-ctx.Done():
  			return ctx.Err()
  		}
  	case <-a.closed:
  		return ErrClosed
  	case <-ctx.Done():
  		return ctx.Err()
  	}
  }
docs: // withSession runs fn with the current session.