Local qwen3.8 realiza llamadas incorrectas con JSON escapado

Describe el problema/error/pregunta

Utilizo n8n localmente en docker e intento usar el nodo de agente de IA y tool calling. Mi ejemplo JSON de subworkflow

¿Cuál es el mensaje de error (si lo hay)?

Por favor, comparte tu workflow

(Select th{
  "nodes": [
    {
      "parameters": {
        "inputSource": "jsonExample",
        "jsonExample": "{\n  \"hosts\": [\n    \"placeholder-host\"\n  ],\n  \"ip_addresses\": [\n    \"placeholder-ip\"\n  ]\n}"
      },
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ],
      "id": "fb339ab6-8a92-4083-bcdb-00528a3b5c9d",
      "name": "When Executed by Another Workflow"
    }
  ],
  "connections": {
    "When Executed by Another Workflow": {
      "main": [
        []
      ]
    }
  },
  "pinData": {},
  "meta": {
    "instanceId": "d6a7edbef0b99d9698822720f64e300bdd09aa993d61389d39eff20f864210f1"
  }
} {
  "nodes": [
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('Filter just originator messages').item.json.chat_history_transcript }}",
        "options": {
          "systemMessage": "You are an Automated IT Access Provisioning Agent. Your task is to analyze the chat transcript and extract firewall access parameters.\n\nCRITICAL PARAMETERS TO FIND:\n1. Source (IP address, range, CIDR, or Hostname/Server name where access starts)\n2. Destination (IP address, range, CIDR, Hostname, or System name where access is needed)\n3. Ports / Port Ranges (e.g., 22, 80, 443, 8000-8080)\n\nSTRICT WORKFLOW RULES:\n1. EXTRACT: Scan the chat text to identify potential Sources and Destinations.\n2. VALIDATE EVERY ASSET: The moment you find a hostname or IP address, you MUST execute the `IT_CMDB_Host_IP_Lookup` tool for each object individually to verify it exists in the company infrastructure. Use strict JSON format when calling tool.  When calling the IT_CMDB_Host_IP_Lookup tool, you must provide the hosts and ip_addresses arguments as raw JSON arrays (e.g., [\"item1\", \"item2\"]). If no hosts or no IP addresses are found in the text, you MUST pass [\"NONE\"] for that specific argument. Do not pass an empty array or null\n3. HANDLE AMBIGUITY: \n   - If the tool returns \"Multiple objects found\", look at the details and ask the user to clarify (e.g., \"I found two servers named CLD.ALPHA (ID-101 and ID-102). Which one do you mean?\").\n   - If the tool returns \"Not found\", inform the user that the asset isn't registered.\n4. GATHER MISSING DATA: If the user provided a Destination but forgot the Source or Ports, do not make assumptions. Politely ask the user in the chat thread to provide the missing pieces.\n5. FINALIZE: Do NOT invoke any ticket creation tools until you have:\n   - Validated both Source and Destination IDs from the CMDB tool.\n   - Identified the specific ports.\n\n[SCHEMA ENFORCEMENT]\nYou must format your tool arguments exactly like this example JSON object. Notice that values are wrapped in true array brackets:\n\n{\n  \"hosts\": [\n    \"7phone-lb01\"\n  ],\n  \"ip_addresses\": [\n    \"NONE\"\n  ]\n}\n"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        -272,
        -400
      ],
      "id": "4f25662d-c5d3-4a61-b768-8eaadbf71aa2",
      "name": "Access Agent"
    }
  ],
  "connections": {},
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "d6a7edbef0b99d9698822720f64e300bdd09aa993d61389d39eff20f864210f1"
  }
} {
  "nodes": [
    {
      "parameters": {
        "description": "Use this tool to get information about host or ip address from it cmdb. The arguments MUST be a raw JSON object, for example: {\"category\": \"other\"}. Do not wrap the JSON into an escaped string.",
        "workflowId": {
          "__rl": true,
          "value": "lWowfpUL2uPVsvTw",
          "mode": "list",
          "cachedResultUrl": "/workflow/lWowfpUL2uPVsvTw",
          "cachedResultName": "IT_CMDB_Host_IP_Lookup"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {
            "hosts": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('hosts', `Must be a native JSON array of strings (e.g., [\"host1\", \"host2\"]). Do NOT pass this as a stringified text or escaped JSON. If no hosts or no IP addresses are found in the text, you MUST pass [\"NONE\"] for that specific argument. Do not pass an empty array or null`, 'json') }}",
            "ip_addresses": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('ip_addresses', `Must be a native JSON array of strings (e.g., [\"192.168.1.1\", \"10.0.0.1\"]). Do NOT pass this as a stringified text or escaped JSON. If no hosts or no IP addresses are found in the text, you MUST pass [\"NONE\"] for that specific argument. Do not pass an empty array or null`, 'json') }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "hosts",
              "displayName": "hosts",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "array",
              "removed": false
            },
            {
              "id": "ip_addresses",
              "displayName": "ip_addresses",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "array",
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2.2,
      "position": [
        16,
        -128
      ],
      "id": "357d4623-8f3b-4da0-8158-f9b6187f83ae",
      "name": "Call 'IT_CMDB_Host_IP_Lookup'"
    }
  ],
  "connections": {
    "Call 'IT_CMDB_Host_IP_Lookup'": {
      "ai_tool": [
        []
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "d6a7edbef0b99d9698822720f64e300bdd09aa993d61389d39eff20f864210f1"
  }
}

Comparte el resultado devuelto por el último nodo

La entrada de herramienta recibida no coincidía con el esquema esperado :multiply: El valor debe ser un objeto no vacío o un array no vacío → en hosts :multiply: El valor debe ser un objeto no vacío o un array no vacío → en ip_addresses el json producido por n8n local es [

JSON generado por Gemini para la llamada de herramienta:

JSON generado por qwen3.8 para la llamada de herramienta:

qwen 3.8 se ejecuta en ollama y llama.cpp, el resultado es el mismo. En la consola de qwen 3.8 en el servidor cuando /set format json todo el resultado son JSONs correctos

¡Hola @pvinogradov! ¡Bienvenido a la comunidad de N8n!!

El tipo json en $fromAI solo acepta un objeto o matriz real, y Qwen y Gemma están enviando la matriz envuelta en una cadena (tu segunda captura de pantalla). Eso sigue siendo JSON válido, por eso /set format json se ve bien en la consola, pero n8n rechaza una cadena allí antes de que el subflujo de trabajo se ejecute.

La solución más fácil es pedirle al modelo una cadena y dejar que n8n la convierta. En ambas entradas, haz clic en la X en «Definido automáticamente por el modelo», cambia el campo a Expression y usa esto para hosts:

{{ $fromAI('hosts', 'JSON array of hostnames, e.g. ["host1","host2"]. Use ["NONE"] if there are none.', 'string') }}

y esto para ip_addresses:

{{ $fromAI('ip_addresses', 'JSON array of IP addresses, e.g. ["10.0.0.1"]. Use ["NONE"] if there are none.', 'string') }}

Tus entradas del subflujo de trabajo están tipadas como matrices, por lo que la herramienta Call n8n Workflow analiza JSON esa cadena nuevamente en una matriz real antes de pasarla, igual que lo que Gemini te proporciona hoy.

¡Parece que está funcionando!

¡Gracias!