I am trying to update a project variable using the graphical modeller. I am using the set project variable algorithm which runs fine but the behaviour is not as expected. Rather than updating the value of the existing variable the algorithm creates a variable using the value from the old variable and sets that new variables value to the new value. I have searched for similar issues and found This Post and I can run the command in the python console and it works fine but I need to do the rest of the processing in the Graphical Modeller
QgsExpressionContextUtils.setProjectVariable(QgsProject.instance(), 'myvar','hello world')