Make Code module: How to pass AI Agent inputs to variables?

:bullseye: What is your goal?

I’m building an AI Agent (Central Order Desk) that uses a Make Code (Python) module as a tool. The agent should pass values like qty, unitPrice, leadTime, etc. to the Code module, which then runs fixed calculations (net/gross totals, delivery date checks) and returns the results.

My question: How do you properly pass AI Agent inputs to Make Code variables? Is there a specific configuration or workaround that makes the agent’s JSON payload accessible via input.get(“variableName”)?

:thinking: What is the problem & what have you tried?

The Make Code module requires at least one input variable. Each variable has a Name and a Value field. The problem: when used as an AI Agent tool, the Value fields don’t offer a “Let AI Agent decide” option – unlike other modules (e.g. SeaTable’s SQL Query field).

What I’ve tried:

  1. 7 variables with empty Values → Code receives None for all variables → int(None) crashes
  2. Typed “Let AI Agent decide” as text in the Value fields → Code tries int(“Let AI Agent decide”) → crashes
  3. Deleted all variables → Module requires at least one variable

:clipboard: Error messages or input/output bundles

The agent correctly sends the JSON payload (visible in the tool call logs):
{
“qty”: 5,
“unitPrice”: 138,
“wishDate”: “”,
“leadTime”: 21,
“bestandIst”: 0,
“reservedQty”: 10,
“plannedBatches”: [{“PlannedDate”: “2026-03-28”, “BatchSize”: 50, “Status”: “In Production”}]
}

But the Code module never receives these values in the input object.
:clipboard: Error messages or input/output bundles
{
“type”: “SandboxCodeExecutionError”,
“message”: “Code execution failed: invalid literal for int() with base 10: ‘Let AI Agent decide’”
}

and when Values are empty:
{
“result”: {
“error”: true,
“message”: “qty und unitPrice muessen groesser 0 sein. Erhaltene Werte: qty=None, unitPrice=None”
}
}

Hey Joachim,

you are a bit ahead of the curve here. The AI agent is not yet meant to use the code app.

What you can do is create a subscenario and place the code app there. Then have the agent call that scenario as a tool and get the output that way.

1 Like

Good news. My free Custom App’s Execute JavaScript code module is AI Agent ready.

Read and install the custom app here

You could easily “translate” your code into JavaScript. Using this module also means it takes at most 1 credit, instead of 2 credits per second (minimum 2 credits) using the Make Code module.

Hope this helps! If you are still having trouble, please provide more details.

@samliew

1 Like

From what you described, it sounds like the AI Agent is sending the JSON, but the Code module does not automatically map those values into its input variables.

So if the input fields in the Code module are empty, the script just gets None. And if you type Let AI Agent decide there, it is treated as normal text, not as dynamic input.

So the issue is probably this: the Code module is not one of the modules where the agent can directly fill those input fields by itself.

I’d treat it more like a mapping limitation than a Python problem.