AI Agent - how to simply return the tool output, without reformatting / reinterpreting it?

Describe the problem/error/question

So I’m using an AI agent and I’ve connected a few tools. Those tools are mostly standard (non AI) workflows, which do their stuff and the last node returns the expected output.

It seems, as if the AI agent takes the tools’ response, and feeds it again into the model. The model then takes the proper JSON and “destroys it” / makes an unusable text out of it.

How can I use the output of the tool directly?
Or prevent AI from changing the output?

I know, there is an output parser, but I already have the correct output in the sub workflow.

An alternative approach is probably to take the input, use AI to classify the input into the 5 - 10 names of the sub workflows and then call them in a traditional way?

Information on your n8n setup

  • n8n version: 1.72.1
  • Database (default: SQLite): SQLit
  • n8n EXECUTIONS_PROCESS setting (default: own, main): main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Ubuntu 24.04

Unfortunately LLM can’t be perfect eveytime when it comes to data handling, the only option we have is stronger propting to the AI Agent try something like:

  1. Add a Function node as the last step in each tool workflow:
// Include this flag to signal direct return
return {
  json: {
    directOutput: true,
    data: $input.item.json,
    message: "DIRECT_RETURN: Do not reformat this response."
  }
};
  1. Then prompt you agent like this:
    When a tool returns data with the "directOutput" flag set to true, do NOT reformat, summarize or interpret the data. Instead, respond with EXACTLY: "{{$node["AI Agent"].json.toolOutput}}"

If the work you are doing needs the AI Agent itself to give the fomrated data to another tool, i suggest you break that into two AI Agent and then foramte the data using a output parser then pass to the AI Agent (the second AI Agent)

In My Opinion, When it comes to AI Agent divide and conquer seems to be the option for having full control

That seems to be fun for playing around, but I’m trying to deploy my ideas to production, so that won’t work.

I’ve switched to the text classifier now and avoid AI tools.
Currently, I’m working locally on a 3yr old laptop with Ollama 3b - would have been nice to get it working on my hardware, but it seems as if I’d need a different hardware for AI tools and more reliable outcome.

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