"AI Agent - Tools Agent" using "MongoDB" return an error said "[object Object]" is not valid JSON"

Describe the problem/error/question

Got an error said “[object Object]” is not valid JSON" when i use “Define automatically by the model” on the “Query”.


========================================================
But when i pass the query into “Fixed” json, it works.


Can anyone help me to figure it out why it happened? Because the query should be “dynamic” that i got from the AI Model.

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.89.2
  • Database (default: SQLite): MongoDB
  • n8n EXECUTIONS_PROCESS setting (default: own, main): main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): npm
  • Operating system: LINUX Ubuntu 22.04.5

Try craft the input as much as you can manually.

[object object] based errors indicate that an object was sent to an input NOT a string value of that object. You can use the function:

.toJsonString() to convert most any object to an actual string.