AI/Airtable : How to make sure that your agent process every input in the array returned by Airtable?

Hello everyone,

Describe the problem/error/question

I am working on a workflow to automatically create a Monte Carlo simulation to analyse expert predictions. The point is to store the expert predictions in Airtable then generate the data on a Google Sheet.

I found out that I needed an agent to adjust a Google Sheet formula to the needed formula for the simulation (sometimes, it is just going to be Turnover-Cost but I could get more intricated formulas afterwards).

So, I tasked my agent on the following :

  • Retrieve the formula stored in Airtable → OK
  • Retrieve the different variables composing the the formula to know in which Google Sheets their data is → NOK

Each time, the agent only processes the first element of the array and is not able to identify the others. I really precised in the prompt to monitor the whole array but it ignores it each time. I have checked in the Airtable tool, it returns every needed variable.

Any idea to help me fix it ?

Thanks a lot in advance ^^

What is the error message (if any)?

Here is the error message : “I found the following information to create the Google Sheet formula for the product Sheeps Sheperd:\n\n- Variable formula from the product with ID P001:\n ‘VAR-001’ - ‘VAR-002’\n\n- Round Variable Information for Round RND-001:\n - For VAR-001:\n - Google Sheet Name: Sheeps Sheperd - RND-001 - VAR-001\n - Variable Name: Turnover\n - For VAR-002:\n - No information found in the Round Variables table for RND-001 and VAR-002 (error case).\n\nIt looks like the variable data for VAR-002 is missing in the round variable data. I can only build a formula for VAR-001.\n\nDo you want me to proceed and generate a formula using only the available VAR-001 variable, or is there anything else you’d like me to check or clarify?”

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: Cloud
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Well, the workflow visualizer did not work so here is the prompt :

“You are an expert statistician tasked to create a Google Sheet Formula that will allow you to draft multiple results to define the value projection for the product through a Montecarlo Simulation : {{ $(‘Get Variables’).item.json[‘Product Name (Lookup)’][0] }}

You first need to retrieve the following information in Airtable :

  • The variable formula (stored in the products table) that indicates the equation you must generate (Filter by id = {{ $(‘Edit Fields’).item.json.Product_id }} in the Airtable Get Product Tool). Process every entry in the output of the tool.
  • The Google Sheet name and variable count where the variables data are stored (identifier stored in the Round Variables table) (Filter by Round = {{ $(‘Edit Fields’).item.json.Round_id }} in the Airtable Get Round Variable Tool). You will receive an array for each variable used for this round, make sure to take them all into account. You can identify the related Variables through the field “ID (from Variable)”

Once you have those information, create a Google Sheet formula that will allow you to solve the variable formula by getting a random variable data from its google sheet each time.

Example :

  • The variable formula is VAR-001 - VAR-002
  • The Google Sheet Identifer, name and variable count for those Variable are the following :
    • VAR-001 Name : Benefits
    • VAR-001 Variable Count : 200
    • VAR-002 Name : Costs
    • VAR-002 Variable Count : 200

“=INDEX({name of the sheet of the first variable}!$A$2:$A${variable count + 1};ALEA.ENTRE.BORNES(1;200))-INDEX({name of the sheet of the second variable}!$A$2:$A${variable count + 1};ALEA.ENTRE.BORNES(1;200))”

The formula created will be the following :
“=INDEX(Benefits!$A$2:$A$200;ALEA.ENTRE.BORNES(2;200))-INDEX(Costs!$A$2:$A$200;ALEA.ENTRE.BORNES(2;200))”

Error cases :
If it looks like you can’t find the information for each variable, check the Round Variable Tool and be sure to inspect every input of the array”

Hi @Romain_Mangattale1! Is this your whole workflow? If so, it makes sense that you are running into issues. Your Agent is referencing nodes that it doesn’t have access to at run time. When your workflow runs, the system prompts in the agent are just swapping out the expressions for error messages since it doesn’t have a node to reference. If you’re trying to reference data coming from the Air Table tools, just use plain English in the system prompt and tell it to use that data, otherwise the instructions for your prompt will read something like “Montecarlo Simulation : [Referenced node doesn’t exist]“, of course hurting the agent’s performance.

Hello @NCione ,

No, it’s not my whole workflow, only the Agent node. The whole workflow works perfectly fine, it’s really the dependence between the Agent and its tool.

Here is the tool answer to gather my round variables :

[
{
"id": 
"recjspHKQ18ZX1pGz",
"createdTime": 
"2025-11-25T16:02:19.000Z",
"Variable": 
[
"recCrzYx7MMOsxDK9"
],
"sheetId": 
471288575,
"sheetName": 
"Sheeps Sheperd - RND-001 - VAR-001",
"Name (from Variable)": 
[
"Turnover"
],
"ID (from Variable)": 
[
"VAR-001"
]
},
{
"id": 
"recnkTi5XcbVNDxFV",
"createdTime": 
"2025-11-25T16:02:19.000Z",
"Variable": 
[
"recAMUQmnDKpuc8Jj"
],
"sheetId": 
2001106121,
"sheetName": 
"Sheeps Sheperd - RND-001 - VAR-002",
"Name (from Variable)": 
[
"Cost"
],
"ID (from Variable)": 
[
"VAR-002"
]
}
]

As you can see, there are two entries (VAR-001 and VAR-002) in the array but the agent always fails to see the second one.

Ah, thank you for clarifying. That is an interesting issue. Hard to say where the root of the issue lies, but I think it would be best to first check if you can manually get the data from VAR-002 if you have not done so already. In the same workflow, set up a manual trigger with the Get Round Variables Airtable record search node and use the exact same inputs that the Agent used (including what it generated to filter by formula). If you do this and get the data you are expecting back, then there’s likely an issue with the agent prompt interpretation or how the tools are being used. If you don’t get the data you’re expecting, we know it’s likely something with the Airtable tool.

2 Likes

Hello @NCione

Thanks for your feedback. I was afraid that I would have to go through this option but it should work indeed. I’ll try it and notice here if it worked or no.

Thanks again ^^

@Romain_Mangattale1 sounds good. Please let me know if you find the root of the issue through this method and if you still need assistance afterwards. Hope this helped!

Hello everyone !

So, it worked. I have added two nodes as input directly in the prompt. Too bad I can’t use the tool though as a limitation.

IMPORTANT : If you had arrays, do not forget to add JSON.stringify, otherwise, you’ll get ‘OBJECT object"‘ in your prompt.

Here is how it goes for the full workflow (it’s more of a prototype to test out how much I could automatize).

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.