# Tool agent for RAG with structured output format

**URL:** <https://community.n8n.io/t/tool-agent-for-rag-with-structured-output-format/55934>\
**Category:** Questions\
**Created:** [September 28, 2024, 7:23pm UTC](https://community.n8n.io/t/tool-agent-for-rag-with-structured-output-format/55934 "2024-09-28T19:23:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Olivi](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/olivi/32/45411_2.png) [@Olivi](https://community.n8n.io/u/Olivi)\
**Post date:** [September 28, 2024, 7:23pm UTC](https://community.n8n.io/t/tool-agent-for-rag-with-structured-output-format/55934/1 "2024-09-28T19:23:17Z")

</div>

## 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 🤒

## 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:** n8n@1.61.0
- **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 ! 😄

---

<div class="post-metadata">

**Author:** ![Jim\_Le](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jim_le/32/45558_2.png) [@Jim\_Le](https://community.n8n.io/u/Jim_Le)\
**Post date:** [October 1, 2024, 2:54pm UTC](https://community.n8n.io/t/tool-agent-for-rag-with-structured-output-format/55934/2 "2024-10-01T14:54:18Z")

</div>

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:

```auto
{ "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.

---

<div class="post-metadata">

**Author:** ![Olivi](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/olivi/32/45411_2.png) [@Olivi](https://community.n8n.io/u/Olivi)\
**Post date:** [October 2, 2024, 4:03pm UTC](https://community.n8n.io/t/tool-agent-for-rag-with-structured-output-format/55934/3 "2024-10-02T16:03:56Z")

</div>

> [@Jim\_Le](#):
>
> chat

Thank you for your help!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [December 31, 2024, 4:04pm UTC](https://community.n8n.io/t/tool-agent-for-rag-with-structured-output-format/55934/4 "2024-12-31T16:04:16Z")

</div>

Closed on December 31, 2024, 4:04pm UTC

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