Hi everyone,
I’m building an app in Retool where users can ask a natural-language question, and Retool’s LLM generates an SQL query based on our database schema. The flow looks like this:
-
We created a Resource that stores our manifest.json (the DB schema Retool’s LLM uses for context).
-
We prompt Retool’s LLM with:
-
The user’s question
-
The parsed manifest schema
-
-
Retool’s LLM returns an SQL query (wrapped in Markdown).
-
We strip away the Markdown fencing and pass the cleaned SQL string into a BigQuery query component.
-
BigQuery should run the SQL and show a results table.
The issue:
Instead of sending the SQL query generated by the LLM, Retool is only sending a single question mark (?) to BigQuery. Nothing else. So the query fails immediately.
As you can see in the screenshots, the value is populated for cleanSql.data, but when I set the cursor outside the curly braces the SQL prepared statement is indeed “?”.
What we’ve checked already:
-
The LLM output looks correct in logs/preview.
-
The cleanup step is working (we confirmed we’re passing a valid SQL string into the query component).
-
The query component is definitely set to run the correct JS variable/return from JS code.
-
Hard-coding the SQL does work, so the issue seems specifically when passing dynamic SQL from the JS code/variable.
-
Disable converting queries to prepared statements is unchecked in the BigQuery resource settings.
Thanks!

