When repeating a command using the "Repeat Command Phrases" feature, command-scoped variables (prefixed with "~"), and command-shared variables (prefixed with "~~") will retain their values, as long as no other spoken command is executed (at which point that command will become what is executed instead; Executing the first command again, then repeating it, will not have the original values still retained).
This occurs even if other (non-spoken) commands are executed, even if those commands use the same variable names (which is correct, just wanted to make sure the cache wasn't overwritten by other commands).
I checked every full version back to 1.7 (in which the "Repeat Command Phrases" feature was introduced), and this applies all to all of them (as a sanity check I made sure command-scoped variables were actually a thing in that version, and they are; That feature was introduced in v1.6.2).
Tested using a number of commands, but the main one is this:
Write [Blue] '~pre = {TXT:~test}' to log
Write [Blue] '~~ pre = {TXT:~~test}' to log
Begin Text Compare : [~test] Has Not Been Set
Set text [~test] to 'test'
End Condition
Begin Text Compare : [~~test] Has Not Been Set
Set text [~~test] to 'test2'
End Condition
Write [Blue] '~post = {TXT:~test}' to log
Write [Blue] '~~ post = {TXT:~~test}' to log
Where the "pre" values should always be "Not set", which they aren't when repeating.
This command is attached, should it be useful for debugging.
EDIT: Appears to be working correctly with v1.8.3.28