Tool agent for RAG with structured output format

Describe the problem/error/question

Hi team!
I would like to have a structured output from a RAG application using a tool agent. The RAG part works well (as long as “Require Specific Output Format” of the tool agent is disabled, everything goes as planned), but when requested a more structured response (by activating this option and adding a auto-fixing output parser, everything falls apart :face_with_thermometer:

What is the error message (if any)?

output values have 5 keys, you must specify an output key or pass only 1 key as output

(I’ve got the same errors with other parsers)

Please share your workflow

Information on your n8n setup

  • n8n version: [email protected]
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): cloud
  • Operating system: Win 10

Thanks a lot for your help ! :smile:

Hey @Olivi Welcome!

I think it’s because you’re using a chat trigger where in the chat flow, it expects a certain response type for the user ie. A json object which looks something like this:

{ "output": "Certainly! The reason why ..." }

Change this to a manual trigger to see the difference.

If you still want to use an output parser, consider changing the “response mode” of the chat trigger to “Using the ‘response to webhook’ node” which allows you to do something with the agent’s response before sending it back to the user.

1 Like

Thank you for your help!