SQL Agent not working

Describe the problem/error/question

The SQL Agent bot is not working and I’m not sure what I’m doing wrong.
This is a very simple workflow. I tried to replicate again with a new database and it still doesn’t work.

What is the error message (if any)?

The error message is:

Could not parse LLM output: I don’t know. Troubleshooting URL: OUTPUT_PARSING_FAILURE | 🦜️🔗 Langchain

And when you get in the logs the AI:

Thought: I should look at the tables in the database to see what I can query.
Action: [[“list-tables-sql”]]
Action Input: “”
Observation: [[“list-tables-sql”]] is not a valid tool, try another one.
Thought:

Please share your workflow

Information on your n8n setup

  • n8n version: 1.78.1
  • Database (default: SQLite): Posgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main): ?
  • Running n8n via (Docker, npm, n8n cloud, desktop app): n8n cloud
  • Operating system: Linux
2 Likes

I’m having the same issue, so it’s probably some bug.
What I did to solve this was attaching a tool to a Tools Agent instead.
And using the $fromAI function.

Works pretty much the same way. You can let the AI decide the entire SQL query or set a certain template for it to follow.

You could also attach another tool that provides sample data from the tables. Or instruct the AI to get some sample data beforehand.

If my reply solves your problem, please remember to mark it as a solution.

1 Like

I can confirm the Issue still exists. I believe that the ‘internal’ SQL prompt is shaky at best.

I think it would be useful to have access to the Internal SQL Agent Prompt text.

But for now, there is a WORKAROUND: Stuck with SQL Agent

Hey @sscholle,

Other Agents are being deprecated, leaving only the Tools Agent.

It’s the only one that I use, to be honest. It can do everything. I don’t really know why the other options existed.


.

So the solution is gonna be the one I gave you above. It does the same job as you were trying to do with the SQL Agent. I use this method a lot and it’s great.

Take a look at a more complex example:

1 Like

Did we answer your question, @sscholle ?

If yes, please choose a solution so we can close this topic.