AI Agent sends nested input, causing placeholder misconfiguration in tool (Perplexity)

Describe the problem/error/question

I’m using the AI Agent node along with a tool (Perplexity) in my workflow.
The problem is that the AI Agent wraps the tool input in a nested object, which causes issues with placeholder resolution in the tool node.

The tool expects:
{ “query”: “how old is bill gates” }

But the AI Agent sends:
{ “query”: { “query”: “how old is bill gates” } }

This breaks the placeholder configuration that expects a string (like {{query}}), resulting in a misconfiguration error.

What is the error message (if any)?

Error in sub-node ‘Perplexity’
Misconfigured placeholder: ‘query’

Please share your workflow

I’m happy to share a sample, but essentially:

  • Trigger: Chat message received
  • AI Agent node
    • Tool: Perplexity
    • Agent sends: { query: { query: “…” } }
  • Perplexity tool node uses placeholder {{query}}, or {{query.query}} inside JSON

Share the output returned by the last node

{
“query”: {
“query”: “how old is Frei Gilson”
}
}

Expected:
{
“query”: “how old is Frei Gilson”
}

Information on your n8n setup

  • n8n version: 1.85.4
  • Database (default: SQLite): none
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker
  • Operating system: ubuntu

Hi @Natan_Souza,

Thanks for the detailed explanation. The issue seems to stem from a type mismatch between how the placeholder is defined and what the AI Agent actually sends.

Currently, your body is set like this:

{ "role": "user", "content": "{query}" }

This expects query to be a string, but the AI Agent wraps it in an object ({ "query": { "query": "..." } }), which breaks the placeholder resolution.

Here are two options you could try:

Option 1: Set the Placeholder Type to “Not Specified”
This allows the tool to accept an object instead of enforcing a string:




Option 2: Adjust the Request Body to Match the Object Structure
If you want to keep the type as “String”, update the body to reference the nested value directly:

{ "role": "user", "content": {query} }

This way, the placeholder resolves correctly even with the nested structure.

1 Like

How are you @Natan_Souza @mohamed3nan

The solution that the respected @mohamed3nan suggested is interesting. I also leave my contribution.

Check if the suggestions below make sense to you.

Edit the Perplexity node and go to the JSON Body field
Modify the placeholder {query} to {query.query}

Modified JSON body…

{
  "model": "llama-3.1-sonar-large-128k-chat",
  "messages": [
    { "role": "system", "content": "Only respond with information from verifiable and credible sources. Include source urls and event dates when possible" },
    { "role": "user", "content": "{query.query}" }
  ],
  "max_tokens": 500,
  "top_p": 0.9
}

I hope I helped in some way.

Big hug

Once you’ve tested and resolved your situation, and don’t mind, please mark my previous post and @mohamed3nan post as the solution (blue box with check mark) so that this ongoing discussion doesn’t distract others who want to find out the answer to the original question. Thanks.

thanks a lot!

I just removed the quotation marks from the placeholder, and it worked! \o/

1 Like

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