Postgres node error handling

Hello,

I have a workflow with IA Agent generating an SQL requests and send it to a postgres tools.

Sometime the SQL statement is bad and postgres node fail.

I have no option to do something on error on the node, like redirect error to agent, asking it to understand the error and reformulate.

Do you have an idea ?

Version 1.122.5

With Tool Calling you have to prompt your error handling unfortunately.
Generally it’s not advised to let the LLM generate a whole SQL query, but only inject data into a already given SQL statement to ensure that no unplanned or even malicious command will be executed.

If you want to use the error handling features of the standard node, I’d recommend to chain an Agent Node > Postgres Node > Agent Node together.

If you share your current Workflow, I may can help you in more detail.

Hi @dmag88 if you want to work around this issue, you could always create a sub workflow which handles the postgres node calling with error handling and call the sub workflow as a tool from your agent instead of the postgres tool directly. This was you can have more control over how you handle errors.

Your other option is to build an MCP server workflow and use the MCP tool.

Hello @Wouter_Nigrini and @salmansolutions

Thanks for helping me !

I tried to trigger a workflow on error (settings : Error Workflow) but It never trigger when the postgres tool fail.

(I launch the workflow with the chat inside the workflow)

When I try @salmansolutions solution to link AI Agent to postgres node to another ai agent node, the postgres node return a an alway different variable output I can’t pass to the next node

for example the output is : total_vcu : 144 because I asked agent to write a SQL to count CPU.

Do you know if another variable on postgres output I can catch ?