{
  "name": "answers/n8n-ai-agent-not-calling-tools - tool-calling reproduction",
  "nodes": [
    {
      "parameters": {},
      "id": "a1000000-0000-4000-8000-000000000001",
      "name": "Run once",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [-220, 200]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "b2000000-0000-4000-8000-000000000002",
              "name": "chatInput",
              "value": "Multiply 23951 by 417 and return only the number. Use the Calculator tool, do not compute it yourself.",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "a1000000-0000-4000-8000-000000000002",
      "name": "Prompt",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [0, 200]
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.chatInput }}",
        "options": {}
      },
      "id": "a1000000-0000-4000-8000-000000000003",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [240, 200]
    },
    {
      "parameters": {
        "model": "google/gemini-2.5-pro-preview",
        "options": {}
      },
      "id": "a1000000-0000-4000-8000-000000000004",
      "name": "Chat Model (SWAP THIS)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "typeVersion": 1,
      "position": [140, 420],
      "notesInFlow": true,
      "notes": "Case B (breaks): a model that does not do structured tool calls. Case A (works): swap model to anthropic/claude-3.7-sonnet or openai/gpt-4.1, re-run."
    },
    {
      "parameters": {},
      "id": "a1000000-0000-4000-8000-000000000005",
      "name": "Calculator",
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "typeVersion": 1,
      "position": [360, 420]
    },
    {
      "parameters": {
        "content": "## What this reproduces\n\nAn AI Agent (Tools Agent) that **does not call the tool it is given**.\n\nThe prompt asks for `23951 * 417` (= 9987567) and forbids the model from computing it itself, so the only correct behaviour is a Calculator tool call. Whether that happens is decided entirely by the model wired underneath the Agent.\n\n**Run it twice, changing only the model on `Chat Model (SWAP THIS)`:**\n\n- Case B, model `google/gemini-2.5-pro-preview`: the Agent returns a JSON blob containing `functionCall` as text, or a wrong/hallucinated number. The Calculator sub-node shows **no execution**.\n- Case A, model `anthropic/claude-3.7-sonnet`: the Calculator sub-node executes and returns `9987567`.\n\nSame graph, same prompt, same tool. The only variable is the model's tool-calling support. That is the point: 'not calling tools' is usually a model-capability problem wearing a workflow costume.",
        "height": 320,
        "width": 420
      },
      "id": "a1000000-0000-4000-8000-000000000006",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [620, 120]
    },
    {
      "parameters": {
        "content": "## Second trap to test\n\nAdd a **second** tool (any node, e.g. another Calculator or an HTTP Request tool), then **deactivate it** (select it, press `D`).\n\nOn some versions the Agent then fails every request that needs *any* tool with:\n\n`Max iterations (10) reached. The agent could not complete the task within the allowed number of iterations.`\n\nReported on n8n 2.9.4 (GitHub issue #26356), closed cant-reproduce, so it is environment- and version-dependent. Delete a tool you do not want, do not deactivate it in place.",
        "height": 300,
        "width": 380
      },
      "id": "a1000000-0000-4000-8000-000000000007",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [620, 460]
    }
  ],
  "connections": {
    "Run once": {
      "main": [[{ "node": "Prompt", "type": "main", "index": 0 }]]
    },
    "Prompt": {
      "main": [[{ "node": "AI Agent", "type": "main", "index": 0 }]]
    },
    "Chat Model (SWAP THIS)": {
      "ai_languageModel": [[{ "node": "AI Agent", "type": "ai_languageModel", "index": 0 }]]
    },
    "Calculator": {
      "ai_tool": [[{ "node": "AI Agent", "type": "ai_tool", "index": 0 }]]
    }
  },
  "pinData": {},
  "settings": { "executionOrder": "v1" },
  "meta": {
    "templateCredsSetupCompleted": false,
    "description": "First-party reproduction for theagentictribe.com/answers/n8n-ai-agent-not-calling-tools. Import into n8n, add an OpenRouter credential, run once per model. No secrets are stored in this file."
  }
}
