How do I use and update global variables in an Agentic Process?

I have multiple branches in my Agentic Process, all of which return a string in their last step. That string needs to be used as an input in an agent after merging the three branches again. Here’s a screenshot:

In the screenshot, you can see two “Generate Email Content” tasks (agents) and two “Escalate” tasks (action tasks). All of these tasks have an output ‘out_EmailBody’. However, these refer to different instances of out_EmailBody. For the “SD_Agent_FormatEmailAsHTML” task, I need EmailBody as an input.
In other words, I’ll need a global variable where I can save the outcome of out_EmailBody for any of my tasks that output this. That’s the only way I can build this process without needing to copy/paste the final two tasks into every branch of my agentic process.

I cannot find any way to do this, nor does it seem to be documented anywhere. I have been trying to use “Update Variables” in the sub-task properties to write the value of out_EmailBody to another instance of EmailBody, but this seems to be bugged at the moment since I’m being told out_EmailBody does not exist, even though I’m selecting it directly from the variable picker:

If I save the above expression anyways, UiPath automatically REMOVES all of the outputs of my task. Here’s before using ‘Update Variables’:


And here’s after:

When testing, it’s clear that out_EmailBody is not being saved into EmailBody:

I’m very confused as to how this is supposed to work. Any tips or workarounds are greatly appreciated.

@avanmeurs

One option that I see here as update is buggy is to use expression in your formatasHTML input to send input based on which output variable is not null so you need to write an if expression to check for null and accordinngly send the output variable which is not null

Hope this helps

Cheers

@avanmeurs, each task will output its own out_EmailBody variable, which means right after the gateway, you should have three variables with name out_EmailBody but coming from different source. There are two ways that I can think of:

  1. for the input to the SD_Agent_FormatEmailAsHTML step, use an expression like this !String.IsNullOrEmpty(vars.var1) ? vars.var1 : (!String.IsNullOrEmpty(vars.var2) ? vars.var2 : vars.var3), replace var1/2/3 with the out_EmailBody variables.
  2. use a script task, pass in all the out_EmailBody vars, and then return a new variable with the value that you want.

Thanks, since this is ‘just’ a tech demo project I eventually settled on a setup where I save the value of the variable into an Excel table just so that the process can fetch the value of it at the end of the BPMN process.
Nonetheless, it feels very odd to me that the concept of a proper global variable is not currently supported. Is it on the roadmap for development?

Data manager for Agentic process is coming as part of Solutions support which should launch soon and will have that support. In the mean time you can also add an output on the start event and updated it later on each of the task outputs.