I recently had the same issue on my 2021, took to local dealer and they ordered a replacement DEF tank. This is apparently a known issue within the GM tech circle.
My DEF level would go from 3/4 to empty saying xx miles to limp mode and after a couple days would show correct level. Take it in when the issue is there if possible and have them scan it for codes.
Mine threw a code that they caught in the service dept.