Unwieldy variables

I am developing an agent. I have main.flow and I declare all variables in main.flow. All router (logic gates) are also in main.flow so that all sub-workflows are invoked in main.flow. The problem is sub-workflows work in isolated contexts so that main.flow does not automatically recognize the variables worked on by sub-workflows.

When invoking a sub-workflow in main.flow, in the configuration tab, I can declare launch variables. When I go into the sub-workflow itself, in the Start block, I can also declare launch variables. So which is which? Do I need to declare launch variables when I invoked the sub-workflow, and also declare the same launch variables inside the Start block of the sub-workflow?

To add to this maintenance nightmare, in each sub-workflow, in the End block, you need to define the return data so that you can pass back the variables to main.flow. And then in the main.flow for that sub-workflow (in the configuration tab), there are output variables that you need to link the outputs of the sub-workflow back to the main.flow.

Why have 2 areas for defining launch variables and 2 areas for defining the return data? There is so much repetition when declaring these variables. What is the best practice here so my work does not become too unwieldy from monitoring all these variables.

Note: I am using the same variable names in main.flow and sub-workflows.

Hi @buboylav,

Could you let me know how you’re triggering the sub-workflows? Do you route the flow to them through Jump blocks or the Run Workflow block?

It’d also help if you could share a remix link to your agent so I can take a closer look at your setup. Here’s how to get the link:

  1. Click the agent’s name at the top left of the editor
  2. Go to the Remixing tab
  3. Enable remixing and copy the link
  4. Publish the agent

I am using Run Workflow block. I sent you through private message the remix link.

Hi @buboylav,

Thanks for sharing the remix link.

Yes, you need to declare launch variables in both the Run Workflow block’s configuration and the Start block of the sub-workflow, and define the output data in the End block as well as the output variables in the Run Workflow block’s configuration.

Run Workflow block is primarily designed for parallel processing of JSON arrays, where each item kicks off its own run and then returns all results back to the main workflow. One example is the Deep Research agent which researches multiple topics in parallel:
https://app.mindstudio.ai/agents/deep-research-b4cce085

Each workflow runs independently and has no visibility into other workflows, which is why you need to declare the variables passed between them separately. You can also find more details on the best practices here:

Let me know if you have any other questions.