ESP32 Bluetooth range limited unless debugging

I am trying to use an ESP32 to play sounds onto a Bluetooth speaker. After a lot of bluetooth problems I decided to start with an example sketch to see if it would work in the basic case. I am attempting to use the example sketch linked here to play a sine wave sound over bluetooth.

When I use platformio.exe device monitor to try to debug the problem, the bluetooth range is excellent, but the moment I run the script without the serial monitor (i.e. disconnect and reconnect to the computer, plug into the wall, etc.), the bluetooth range becomes severely limited. Unless the speaker is within a few inches of the ESP32, it does not play any sounds. This does not happen when I have the device monitor running. My computer does not have bluetooth support (so the ESP32 cannot be using the computer’s bluetooth range), I have tried multiple cables with multiple outlets to no avail. I have also tried multiple bluetooth speakers and they all result in the same issue: bluetooth range is limited unless the device monitor is running. I currently do not have any pins connected to anything and I have tried using 3 different ESP32s.

Here is what my platformio.ini file looks like:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
board_build.partitions = huge_app.csv
lib_ldf_mode = chain+
lib_deps = 
	https://github.com/pschatzmann/arduino-audio-tools
	https://github.com/pschatzmann/ESP32-A2DP

It doesn’t seem like anyone else that is using this library has this problem.

What is the device monitor doing that could be making the script work correctly?
Am I missing a setting somewhere in my configuration that is causing the ESP32 to not have the proper Bluetooth range unless the device monitor is running?

EDIT: I logged an issue on the github as well, but I think it has something to do with device monitor script that PlatformIO uses: ESP32 Bluetooth Source Range limited when not debugging · Issue #1526 · pschatzmann/arduino-audio-tools · GitHub