Agent returning null when invoked from studio

Hello,

I am creating a process where I am invoking a bot and then passing its value 1 by 1 to the agent using a for loop. I am then invoking the agent by using the “Run agent” activity and passing the input parameters as shown in the screenshots. I am getting null as the output from the agent (out_group).
I have attached screenshots from the UiPath cloud studio as well where you can see my input and output arguments for the agent. Also, the agent is running fine on UiPath cloud studio but I am getting null when invoking it on UiPath studio app.

Can anyone please help me with this?






Thanks in advance!

Hi Parth,

This issue usually happens due to one of the following:

  1. Check “Wait for Completion” in the Run Agent activity — it must be enabled to get outputs.
  2. Verify out_group is marked as Out in both Agent Builder and Studio.
  3. Ensure correct output mapping — use RunAgentOutput("out_group").ToString or map it in the Output property.
  4. Update packages — make sure you’re using the latest UiPath.System.Activities and UiPath.Agent.Builderversions.

Let me if you need any assistance

Thanks for the quick reply @Mir.Jasimuddin !

  1. “Wait for job completion” is selected in Run Agent properties like you said.
  2. out_group is defined like this in studio and on cloud studio. Let me know if this is correct!

  3. can you please elaborate on the output mapping regarding what needs to be done on studio?
  4. I have updated the packages like you suggested.

Best,
Parth

Hey Parth,

Glad you already checked the earlier points.

For the output mapping — after you run the agent, make sure you’re storing the result in a variable (like agentResult) in the Output → Result field of the Run Agent activity.

Then, just use an Assign like this:

finalGroup = agentResult("out_group").ToString

That should give you the value from the agent. Let me know if you need help setting this part up!

@Mir.Jasimuddin I am capturing agent’s output into an “Out” argument out_group like this:

but its returning null

Hey Parth,

Thanks for sharing the screenshot, that helps.

Your setup looks mostly correct:

  • “Wait for job completion” is selected
  • You’re capturing the job data in agentresult
  • You’ve mapped out_group in the output arguments

The likely issue is inside the agent process itself. Even though out_group is declared, it won’t return anything unless the agent explicitly assigns a value to it before finishing. Just having the argument isn’t enough—make sure you’re setting it with something like out_group = <your value> at the end of the agent workflow.

Also, as an alternative approach, you can remove the out_group from the Output Arguments section and instead use:

finalValue = agentresult("out_group").ToString

right after the agent runs. This sometimes avoids issues with argument bindings.

Let me know how it goes or if you want help reviewing the agent’s logic.

@Mir.Jasimuddin thanks for clarifying. Here’s what I get when i run the agent. I’m getting out_group value in the agent as expected at the bottom.

Also, I have defined the output arguments like this:

Please note that the agentresult which is the JobData is also being returned as null when I tried capturing it in finalValue like you suggested.

Let me know if i need to make any changes to this.

Hey @Parth_Sharma, can please check the bellow points:

  1. The issue is with the activity you’re using.
    You’re using the Run Job activity from UiPath.System.Activities, which is meant for standard processes, not for agents created using Agent Builder.

  2. Use the correct activity.
    Install and use the Run Agent activity from the UiPath.Agent.Builder package. This is specifically built to handle agents and return outputs like out_group properly.

  3. Map the result correctly.
    After using the correct Run Agent activity, assign a variable (like agentResult) to the Output > Result field. Then, extract the value using:

finalGroup = agentResult("out_group").ToString
  1. Retest your process.
    Once you switch to the right activity and set the output correctly, your agent’s output should come through as expected.

Let me know if you need help.

@Parth_Sharma

Can you open advanced wditor for arguments and use the below expression to pass your arguments Instead of using data mapping please..are you on a studio version less than 25?

New Email_Rewriter_Input() With {
    .feedback = "sample feedback", 
    .originalEmail = "sample email content"
}

Also please turn on fail when job fails so that if there is any error it would throw as well

Cheers