I think it might be useful to have a read at this other discourse post:
to have a better understanding of escaping in macros.
As written there, each input generally has to be escaped once and exactly once.
So for your added example, you also just avoid escaping model
(like done for args
in the previous answer) inside this line:
ref = :(add_variable($(esc(model)),$(args)))
as it will anyhow be escaped once you escape the quote returned by the macro.