Agent in step cannot override global docker agent?

I have a pipeline where multiple stages of tests are run using customized testing Docker image. I’m trying to override an agent in one of the stages so that kubectl commands in it could be run on the Jenkins node itself, instead of container:

pipeline {
  agent {
    docker {
      image 'mycustomimage'
      registryUrl 'https://mycustomregistry'
    }
  }
  stages {
    stage('restart gateway before tests') {
      agent any
      steps {
        script {
          withKubeConfig([credentialsId: 'kubernetes', namespace: 'default', restrictKubeConfigAccess: true]) {
            sh "kubectl rollout restart deploy/gateway"
          }
        }
      }
    }
    stage('Run tests stage 1') {
      steps {
        script {
          echo "bla1"
        }
      }
    }
    stage('Run other tests stage 2') {
      steps {
        script {
          echo "bla2"
        }
      }
    }
  }
}

This always results in the hanged pipeline just after kubectl command is executed:

process apparently never started in /srv/jenkins/workspace/regression-testing_PR-701@2@tmp/durable-7d760c52

Also, at the beginning of the run I always see this message:

Warning: JENKINS-30600: special launcher org.jenkinsci.plugins.docker.workflow.WithContainerStep$Decorator$1@19960d70; decorates hudson.Launcher$LocalLauncher@3503c55d will be ignored (a typical symptom is the Git executable not being run inside a designated container)

If I set global agent to agent any and then override agent to Docker image in the test stages, it works. However, I don’t want to override this way as I have multiple testing stages and I don’t want to repeat Docker agent configuration for all of them.

Is this a bug, or you cannot override container agents at all?

Agent any is satisfied by the image based agent already in use, you need to explicitly request a real node or a node label.