I believe that best way in your scenario is ether not use auto-shutdown or identify better time to shutdown build agents when you are sure that build is not happening.
Honestly, it's better to manage agent lifecycle from Azure DevOps like Microsoft does for Microsoft hosted agent. You may also can try new feature of Azure DevOps called Scale Set Agents which is in preview now. It's designed exactly to manage your self-hosted agents and scale them up and down as needed. That will allow you to keep agent cost usage on optimal level possible.