Environment variables don't update unless agent redeployed

I have an environment variable set on a Device Group through settings → environment variables.
This is accessed through __VAR in the agent code.
When I change the value, the agent seems to restart but the value of the variable does not update unless I recompile.

Is this the correct behavior?

Is there some other mechanism I can use where it will update immediately?

Kind of. The restart is a semi-bug, but otherwise what you’re seeing is expected behaviour: the __VAR values are baked in at compile time, so you will need to redeploy your app to read the updated values in code. This has been rectified in the docs, BTW.