[Open IA Node] GSheet tool returns all sheet

Hi everyone, I’m just starting to learn this amazing tool, n8n, and I’m trying to build a chatbot that can give users information about certain products, including price calculations.

I have an OpenAI node connected to a Google Sheets tool.
In this Google Sheet there’s a list of all the products (a very long list), and when I ask the OpenAI chat for information about a product I get this error:

“400 ‘tool_outputs’ too large: the combined tool outputs must be less than 512 KB.”

Looking at the Google Sheet output in Executions, I see that it returns the entire sheet with no filters every time. How can I set a filter so it only returns the rows I want?

Unfortunately, because I’m using an AI Tool node, I can’t place any other nodes in between. What can I do?

Thanks

Hey there! Welcome to the community :slightly_smiling_face:

The error you’re seeing happens because the Google Sheets node is sending back the entire spreadsheet, which is way too much for the OpenAI Tools Agent to handle.

Instead of connecting the whole sheet directly to the AI Agent, try this:

  1. Before your AI Tool node, add a Google Sheets node.
  2. In the Sheets node use “Read Rows” operation.
    Apply a filter so it only returns the row(s) matching the product the user asked about.
  3. Now connect the AI Tool node to that filtered data.

Alternatively you can set a sub-workflow to get only one rows at the time

Lmk
Cheers!

Hi @Gallo_AIA
thanks for the quick reply.

Everything is clear now.

Just a few questions:

  1. If I put the Google Sheet before the AI node, how will I know what information the user is looking for? Wouldn’t it be better to let the AI interact first and then have it query the sheet directly?
  2. Another workflow is probably the right solution, but I’d like to keep everything inside the existing workflow to avoid spreading things out. Should I use an HTTP Request for that?
  3. I tried using filters directly in the Google Sheet with the “Defined automatically by the model” option, but the output comes back empty:

json

[
{
“response”:
}
]

And this is the input:

json

[
{
“values0_Value”: “finestre”,
“values1_Value”: “”,
“values2_Value”: “”,
“values3_Value”: “”,
“values4_Value”: “”
}
]

if the user’s input is unstructured, it does make sense to let the AI interpret it before the sheet.


Option 1: Two-step logic in a single flow

  1. Let the AI extract the product name from the user’s question.

You can use the AI Tool just for this step (e.g., prompt: “Extract the product name from this message.”).
Save the result (e.g., “finestre”) (are you Italian? :heart_hands:) in a field like productName.

  1. Then use that productName to query Google Sheets with a filtered request, just like before.

This keeps everything in one single workflow.


Option 2: Direct Sheet lookup by AI

You mentioned trying to let the AI query the sheet directly using the “Defined automatically by the model” option, but you’re getting an empty result. That usually means the table headers in Sheets weren’t clear or structured enough. Make sure the first row has clean field names (e.g., “product”, “price”, “category”).

The AI prompt didn’t provide enough context or structure to generate a useful filter. You can help the AI with a clearer system message or example.

Something like:

“You have access to a spreadsheet with products. Use the ‘product’ column to find the row that matches the user’s request.”

Also: If you’re getting “values0_Value” etc. in the output, it likely means your sheet doesn’t have proper column headers. Add them in row 1, and n8n will use them automatically.

Btw no need to use an HTTP Request unless you’re calling an external API.
Google Sheets can handle this fine with the regular Sheets node, you just need a bit of logic around filtering or structuring the data first.

Cheers!

Hi @YuppY! Great question — this is a common issue when using the AI Tool node with large datasets like full Google Sheets.

Problem

The error:

400 'tool_outputs' too large: the combined tool outputs must be less than 512 KB.

happens because the AI Tool node fetches the entire sheet, and you can’t insert a filter node in between due to the current tool limitations.


Solution: Use Google Sheets as a tool with filtering built-in

You can filter directly within the tool definition using the toolDescription. Here’s how:


Suggested Fix:

When you register the Google Sheets tool, describe its filtering behavior in the toolDescription, like:

Use this tool to look up a product by name. Only return the row that matches the product name exactly. Do NOT return the entire sheet.

This helps the AI agent generate queries with a clear constraint like:

SELECT * FROM sheet WHERE product = 'Product Name'

Or if you’re using a predefined function like match_product(product_name), define that function explicitly in your tool description.


Bonus Tips

  • Make sure the sheet is properly structured (headers in the first row, clean column names).
  • If your sheet is too large, consider uploading it to a database like Supabase and querying via SQL — much faster and scalable.

Let me know if you’d like a concrete example of the tool JSON definition with filtering!

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