RunFunction Variable Persistence, Writes Not Visible Downstream

Update: From doing more research and reading other peoples problems with this - I think I need to find a different platform to achieve my goals. But if the issue below can be resolved let me know.

Message to MindStudio Support / Engineer

I am building a step-by-step “decision safety check” in MindSpring. It takes a proposed action, runs it through a fixed set of checks, saves the results so each step can use them, and then produces a clear report that says whether the action can proceed, must pause, needs escalation, or must be denied, along with the reasons.

I need to confirm whether MindStudio supports a basic but required data-flow pattern for the system I’m building.

I’m implementing a constitutional workflow where:

  • decisions are evaluated in discrete steps,

  • each step must deterministically persist its result,

  • and downstream steps must read that state without recomputation or hidden logic.

The core pattern I need is:

runFunction → persist variable → downstream block reads it

Concretely:

  • A runFunction computes or transforms a structured object (for example gateResults)

  • The function calls setVariable() to overwrite that variable

  • A later Display or logic block reads {{gateResults}} reliably

At the moment, values written with setVariable() are rendering as undefined downstream.

I understand that MindStudio may require variables to be declared in an output / variables contract, but it’s unclear:

  • Where in the UI that contract is defined (function asset vs. canvas node)

  • Whether this pattern is fully supported in CloudRunner at all

Because this is a constitutional workflow, I need:

  • explicit state persistence,

  • predictable scope,

  • and verifiable step-by-step execution.

My questions are:

  1. Is it possible in MindStudio for a runFunction to reliably overwrite a workflow variable so downstream blocks can read it?

  2. If yes, where exactly do I declare the output variable contract that enables this (panel name / setting location), with a minimal working example?

Clarifying this will determine whether this workflow can be built on MindStudio at all.

Sample code I am trying to run:

Send this exact JavaScript snippet and explain that it runs in a runFunction block.

async function main(config) { // overwrite a workflow variable setVariable("gateResults", { outcome: "PROCEED", rationale_display: "No constraint violation identified." }); }

Then say the downstream Display Content renders:

Outcome: {{gateResults.outcome}} Rationale: {{gateResults.rationale_display}}

sample build:

https://app.mindstudio.ai/agents/gate-result-checker-9782c851/remix

Why this code is ideal

  • It uses no inputs

  • It uses one variable

  • It uses setVariable() exactly once

  • It tests nested object access

  • It matches your constitutional workflow need: compute → persist → render

One-line framing to include

“This is the smallest example of the pattern we need to support: a runFunction overwrites gateResults, and downstream blocks read it deterministically.”

Hi Philip,

Thanks for the detailed post and welcome to the Community!

The flow you’re describing is fully supported in MindStudio. The issue is that setVariable() isn’t a valid method in Custom Functions. To persist variables from a Custom Function that downstream blocks can read, use ai.vars instead.

Here’s an updated version of your Agent:
https://app.mindstudio.ai/agents/updated-gate-result-checker-c83e59ef/remix

And here’s another example of an Agent that assigns values to workflow variables and iterates upon them:
https://app.mindstudio.ai/agents/sample-agent-with-two-custom-functions-8e0b385e/remix

You can find more details in our documentation:

Let me know if you have any questions!

I am building a larger agent workflow that uses Run Function blocks to persist and output responses before rendering a display-only report but the fields all come out blanks.

I have used the ai.vars settings you suggested but it seems not correctly.

Is there a simple fix I am missing ?

Link:

https://app.mindstudio.ai/agents/1-alex-fix-rhythming-key-kernel-v29-393d0d02/remix

Inputs for Questions

  • declaredAction: I will draft a private internal memo summarizing the issue.

  • negativeIntake: Must not publish, post, or share publicly.

  • pressureFactors: Uncertainty

  • undoability: Undoable

  • publicness: Private

  • representation: Self

Hi @Philip_R,

Thanks for the link!

In my previous message, I shared an example of an agent that uses a VM environment. Apologies for the confusion on that.

In your agent, you simply need to remove the wrapper. Here’s a remix link to your adjusted agent:
https://app.mindstudio.ai/agents/copy-of-1-alex-fix-rhythming-key-kernel-v29-aed59cd4/remix

Here’s also a remix link to another agent I created that demonstrates this process:
https://app.mindstudio.ai/agents/data-transformer-b345422b/remix

The Agent follows these steps:

  1. Saves an array to a variable
  2. First Custom Function removes the third item
  3. Second Custom Function converts it to an object

Let me know if you have any questions.