[Error - Langchain Integration - AI Tool Agent] Received tool input did not match expected schema at DynamicStructuredTool.call

Describe the problem/error/question

I am geting a generic error every time I use a specific tool agent. It seems that the error is caused by an input on a specific tool, but I have already tried changing and better defining the input. The weird thing is that the error happens on random times and not in all executions.

What is the error message (if any)?

{
“errorMessage”: “Internal error”,
“errorDetails”: {},
“n8nDetails”: {
“n8nVersion”: “1.53.2 (Cloud)”,
“binaryDataMode”: “filesystem”,
“stackTrace”: [
“Error: Received tool input did not match expected schema”,
" at DynamicStructuredTool.call (/usr/local/lib/node_modules/n8n/node_modules/@langchain/core/dist/tools/index.cjs:88:19)“,
" at processTicksAndRejections (node:internal/process/task_queues:95:5)”,
" at /usr/local/lib/node_modules/n8n/node_modules/langchain/dist/agents/executor.cjs:479:27",
" at async Promise.all (index 0)“,
" at AgentExecutor._call (/usr/local/lib/node_modules/n8n/node_modules/langchain/dist/agents/executor.cjs:471:30)”,
" at AgentExecutor.invoke (/usr/local/lib/node_modules/n8n/node_modules/langchain/dist/chains/base.cjs:58:28)“,
" at Object.toolsAgentExecute (/usr/local/lib/node_modules/n8n/node_modules/@n8n/n8n-nodes-langchain/dist/nodes/agents/Agent/agents/ToolsAgent/execute.js:144:30)”,
" at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/@n8n/n8n-nodes-langchain/dist/nodes/agents/Agent/Agent.node.js:349:20)“,
" at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:728:19)”,
" at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:673:51",
" at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:1086:20"
]
}
}

Information on your n8n setup

  • n8n version: 1.53.2
  • **Running n8n via n8n cloud
  • Operating system: windows

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:
  • n8n version: 1.53.2
  • Database: default: SQLite
  • n8n EXECUTIONS_PROCESS setting: default: own, main
  • Running n8n via: n8n cloud
  • Operating system: Windows

Hi @Artur_Ferreira_Padua

Thanks for posting here and welcome to the community! :partying_face:

Can you please update your n8n version to the latest ? I think this is an old bug, we fixed.

Hi @ria ,

Thanks for the reply.
We have tested on the new version and the error keeps hapenning!

If you need to have a deeper look, here are the worflow IDs and executions we’re ecountering the error:

  • Workflow: at8lCsgaqn5jK1gH - Execution ID: 27430
  • Workflow: XBTuRl5hPMzRWkAe - Execution ID: 27432

Hi @Artur_Ferreira_Padua

Thanks for the update!

We do not have access to your workspace, therefore could you please share the workflow that you are getting this error, so we can try to reproduce it? (Ideally with some dummy data pinned)

Thanks! :slight_smile:

@Artur_Ferreira_Padua, did you resolve this? I’m also getting this issue

Hi @Wayne @Artur_Ferreira_Padua

We released a possibly related fix with 1.64.0

Can you please update and see if that resolved it?

@ria I’ve just updated and now all my tools are returning undefined :frowning:

Yep all my tools are completely broken after the update.

The issues seem to be when the endpoint requires authentication.

Hi @Wayne

Can you share your workflow for reproducing this? I will raise this with our AI engineers.

Thanks!

Is there a way I can share it privately ?

We just need to see how you’ve configured it and which nodes you’re using etc.
It does not share your credentials by posting here. And you can modify the JSON as well to remove sensitive information.

Tip for sharing your workflow in the forum

Pasting your n8n workflow


Ensure to copy your n8n workflow and paste it in the code block, that is in between the pairs of triple backticks, which also could be achieved by clicking </> (preformatted text) in the editor and pasting in your workflow.

```
<your workflow>
```

Make sure that you’ve removed any sensitive information from your workflow and include dummy data or pinned data as much as you can!


But if it’s more comfortable for you, you can also DM me.

I shall DM, there lots of work gone into this one and it’s a client project so not for public consumption :slight_smile:

Hi @Wayne @Artur_Ferreira_Padua

Sorry guys I just saw this now, but we actually have another fix (in particular for the HTTP tools with predefined credential types) - this should help you @Wayne. You can follow it up here:

But that’s actually a different issue than the original forum post by @Artur_Ferreira_Padua - Would be good to hear some feedback from you as well.

Thanks!

Thanks Ria, is this under release 1.64.1? There are no release notes as yet.

Hi @Wayne

This should be released today and will then be in 1.64.2
:crossed_fingers:

1 Like

Hey ria!
Tks for reaching out.
Unfortunately the fix you sent won’t be helpfull since I am using mostly VertexAI and Anthopic as LLM Providers. By the way, we’ve this week updated to the version 1.64.1 and the bug keeps happening.

Watching the log I have realized a behaviour pattern even when JSON Schemas and LLMs vary. And the behaviour is that on the first run, the Agent nail the job defining a correct json schema with the property data structured, but the agent runs the LLM one more time and then come the error. The autofixing output parser also hasn’t beem able to fix. I’ll provide as much data as possible in the examples and if you need something more I can DM.

Here is the workflow:

Here is the json the agent structured on the first run:
{
“action”: “Final Answer”,
“action_input”: “{\n "__structured__output": {\n "__structured__output__array": [\n {\n "name": "João da Silva",\n "role": "Titular",\n "maritalstatus": "Casado",\n "healthplan": "ALICE CONFORTO",\n "dentalplan": "",\n "coparticipation": "false",\n "phone": "1199709875",\n "email": "[email protected]",\n "companyrole": "",\n "dependent_of": "",\n "relationship": ""\n },\n {\n "name": "Maria fatima",\n "role": "Dependente",\n "maritalstatus": "Casado",\n "healthplan": "ALICE CONFORTO",\n "dentalplan": "",\n "coparticipation": "false",\n "phone": "",\n "email": "",\n "companyrole": "",\n "dependent_of": "João da Silva",\n "relationship": ""\n }\n ]\n }\n}”
}

Here is the result after the secund run and using the autofix output parser. Btw, I’ve already tried not using the autofix.
[
{
“output”: [
{
},
{
}
]
}
]

The unwanted behavior is either a empty json as above or this generic error message that I got in the log of the second run on the LLM:
"". Error: SyntaxError: Unexpected token '`', "json
{
“… is not valid JSON”

Could you please help us asap? This error is making out application very unstable and as I’ve researched it looks like that is an instruction on how the AI Agent is parsing the json that seems native to the n8n.

I solved it by replacing Chat-GPT with Groq

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