What worked for me was to explicitly state in the prompt to store a value in a particular referenced variable (@.....). Also make sure that you specified that the variables are writable (r+w). Lastly sometimes it's easier to split the job into multiple AI tasks in normal nodes instead of a single autonomous node.