Execute Subworkflow with AI Agent Node

Describe the problem/error/question

I’m using an AI Agent node that executes a subworkflow.

Some of the fields of the subworkflow should be filled by the AI Node. When I fill only one field with the AI Node it works. As soon as the AI Agent should fill two fields it doesn’t work anymore.

I have tried searching a lot and I cannot find why it will fail. Probably somewhere some minor tweak I need to adjust I just don’t happen to find it.

Here is my very simple Agent:

This execution will fail:

The error looks like this:

This is the input into the subworkflow from the agent.

[
  {
    "query": {
      "vdb_query": "Purora emotional social media post examples",
      "filter": "{\"must\":[{\"key\":\"type\",\"match\":{\"value\":\"social_media_post\"}},{\"key\":\"tone\",\"match\":{\"any\":[\"emotional\",\"story\",\"heartfelt\",\"inspirational\"]}}]}"
    }
  }
]

This is all the same but now I only fill one component with AI. Now all works.

This is the input from the AI Agent

[
  {
    "query": {
      "vdb_query": "Purora Social-Media-Stil Beispiel: emotionaler Post über einen Smoothie, achtsamer Lebensstil, Gemeinschaft, Gesundheit, einfache Sprache, strukturierte Aufzählung mit Emojis"
    }
  }
]
[
  {
    "result": {
      "points": [
        {
          "id": "e1b4b10c-41bd-5ae4-9e3d-d66141b71e10",
          "version": 46,
          "score": 0.6839099,
          "payload": {
            "ID": "23",
            "Topic": "Smoothie am See",
            "Type": "Community",
            "Aktion": "Bewusstseinbildend",
            "Style": "Inspirierend",
            "TargetGroup": "Alle",
            "Platform": "Instagram, Facebook",
            "Hashtags": "#mypuroramoment #purdu #changeforthebetter #lake #healthybreak ....
    "status": "ok",
    "time": 0.001376942
  }
]

What is the error message (if any)?

This is the output of the subworkflow unfortunately it doesn t contain an Error Message.

{
  "errorMessage": "",
  "errorDetails": {},
  "n8nDetails": {
    "n8nVersion": "1.112.4 (Self Hosted)",
    "binaryDataMode": "default",
    "cause": {
      "with_vector": false,
      "with_payload": true,
      "isTest": false,
      "collection": "purora",
      "limit": 5,
      "offsett": 0,
      "Timeout": 100,
      "embedding": "text-embedding-3-small",
      "encoding_format": "float",
      "score_threshhold": 0,
      "vdb_query": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('vdb_query', `Write here the text you want to query the Qdrant Database. Just a string asking it. `, 'string') }}",
      "filter": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('filter', `A Qdrant filter object, formatted as a valid, minified JSON string. \\\\n\\\\n**CRITICAL:** The syntax MUST be 100% perfect Qdrant filter format or the entire operation will fail. Do not include any explanations or markdown formatting. \\\\n\\\\n**STRUCTURE:** \\\\nThe top-level object must have a key of \\\\must\\\\, \\\\should\\\\, or \\\\must_not\\\\. The value is an array of condition objects. \\\\n\\\\n**CONDITION TEMPLATES:** \\\\n**For exact text or keyword matches**, use the match template: \\\\n {\"key\": \"field_name\", \"match\": {\"value\": \"string_to_match\"}} For multiple text or keyword matches**, use the match and any template: \\\\n {\"key\": \"field_name\", \"match\": {\"any\": [\"string_to_match\", \"string_to_match2\"]}}`, 'string') }}"
    }
  }
}

Please share your workflow

This tool doesn’t work:

This tool works:

This is the subworkflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.112.4 (Self Hosted)
  • Database (default: SQLite): pqsql
  • n8n EXECUTIONS_PROCESS setting (default: own, main): own
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: QNAP NAS

Hey, try to move this long description from the second variable into the prompt or system prompt for your AI. Fix the \n and general formatting too.

Also, in the prompt or system prompt be extremely specific and use words like ALWAYS or ONLY to ensure the agent always calls X tool with the required number and type of parameters.

It’s almost always a prompt issue, so get testing :slight_smile:

1 Like

Hi Thanks for the fast reply. That worked!
I’m sorry I was a bit surprised that apprently the input in the variable promt would make problems.

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