code: def test_agent_stop_polling(runner, monkeypatch, user, test_settings):
      def patched_pop_empty_queue(self, queue):
          # patch to no result, agent should read stopPolling and stop
          return None
  
      _setup_agent(monkeypatch, patched_pop_empty_queue)
  
      monkeypatch.setattr(
          "wandb.sdk.internal.internal_api.Api.get_launch_agent",
          lambda c, i, g: {
              "id": "mock_agent_id",
              "name": "blah",
              "stopPolling": True,
          },
      )
      monkeypatch.setattr(
          "wandb.sdk.internal.internal_api.Api.update_launch_agent_status",
          lambda c, i, s, g: {"success": True},
      )
  
      args = ["--entity", user, "--queue", "default"]
      with runner.isolated_filesystem():
          result = runner.invoke(cli.launch_agent, args)
  
      assert "Shutting down, active jobs" in result.output
  
imports: import json
  from unittest.mock import Mock
  import pytest
  import wandb
  from wandb.cli import cli
  from wandb.sdk.launch.errors import LaunchError
label_desc: Use image node_id 8 for calling a global function with example usage: test_agent_stop_polling(runner, monkeypatch, user, test_settings) and returns: None