AutomationFlowsAI & RAG › Build AI Agents with Think-plan-act Architecture Using Llama-4 Reasoning

Build AI Agents with Think-plan-act Architecture Using Llama-4 Reasoning

Original n8n title: 🧠 Build AI Agents with Think-plan-act Architecture Using Llama-4 Reasoning

ByLucas Dias @devreis on n8n.io

🧠 A plug-and-play n8n workflow that adds LLM-powered reasoning, planning, and action to your automations — with prompts, schemas, and full agent logic included.

Webhook trigger★★★★★ complexityAI-powered33 nodesOpenRouter ChatOutput Parser StructuredOutput Parser AutofixingAgent
AI & RAG Trigger: Webhook Nodes: 33 Complexity: ★★★★★ AI nodes: yes Added:

This workflow corresponds to n8n.io template #3489 — we link there as the canonical source.

This workflow follows the Agent → OpenRouter Chat recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "sWMvGTUPwoijgINx",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "AI think mode",
  "tags": [],
  "nodes": [
    {
      "id": "a96af4c4-3a5a-4928-91ab-612fd271e494",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        560,
        -480
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "25e747a6-9158-454f-84a9-e2f9c2c5a946",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        820,
        -280
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "f11fac1a-b3e8-46eb-b199-e1a9a99477e1",
      "name": "OpenRouter Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        700,
        -280
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "38aa38ce-80bf-4d80-b80c-3964035a7ded",
      "name": "OpenRouter Chat Model4",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        60,
        -480
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "a5866da9-3fea-4286-8057-e5b510655d88",
      "name": "OpenRouter Chat Model5",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        160,
        -280
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "8e9c9639-5818-4d88-8e84-ec3f4719583a",
      "name": "Thinking output parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserAutofixing",
      "position": [
        180,
        -480
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "53dd1a18-1982-4192-91b8-fabc163910d7",
      "name": "Task Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserAutofixing",
      "position": [
        680,
        -480
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "3644ecec-c848-4d9e-b860-507da11644d1",
      "name": "Structured Output Parser1",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "notes": "This is the JSON Schema template for the output.",
      "position": [
        340,
        -280
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "28ee03ed-ea71-481f-a0cb-f1e75cd9620a",
      "name": "start-thinking",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -380,
        -500
      ],
      "parameters": {},
      "notesInFlow": true,
      "typeVersion": 2
    },
    {
      "id": "afbf5a6b-ab5a-499e-a216-982667b151e6",
      "name": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "notes": "You should connect with the rest of your flow.",
      "position": [
        1060,
        -500
      ],
      "parameters": {},
      "notesInFlow": true,
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "6deb07ea-7c34-4567-aa17-70ece8f4f13b",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        580,
        -920
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "0e24f818-49af-4718-8a89-eeeda99d7ae7",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        940,
        -280
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "e1cf056c-9ba1-4d5c-858a-ac1c2bb02078",
      "name": "Think",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        100,
        -700
      ],
      "parameters": {},
      "retryOnFail": true,
      "typeVersion": 1.8,
      "alwaysOutputData": true
    },
    {
      "id": "99cc0383-3175-4e21-9522-4ab521107f21",
      "name": "Act",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        580,
        -700
      ],
      "parameters": {},
      "executeOnce": false,
      "retryOnFail": true,
      "typeVersion": 1.8,
      "alwaysOutputData": true
    },
    {
      "id": "193a8345-bac4-4109-9aaf-d29b3c26fb69",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -520,
        -660
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "9000de25-ecf4-4e23-8c31-0a41ec21f5aa",
      "name": "OpenRouter Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        580,
        500
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "da53cf96-9111-429e-afc0-b92e608e3a94",
      "name": "Structured Output Parser2",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        840,
        700
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "f9869489-141a-405b-aca2-26a1dedfd35d",
      "name": "OpenRouter Chat Model3",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        720,
        700
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "1eef7804-a332-42a5-a66d-d1b02d91a63f",
      "name": "OpenRouter Chat Model6",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        80,
        500
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "b232217c-e90e-42e8-a5df-d6975ae864a5",
      "name": "OpenRouter Chat Model7",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        200,
        700
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "d3a32b6a-551d-4bf5-a453-3a368e60275c",
      "name": "Thinking output parser1",
      "type": "@n8n/n8n-nodes-langchain.outputParserAutofixing",
      "position": [
        200,
        500
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "f0be0220-9549-4ac5-80c5-95e10e8a89e3",
      "name": "Task Output Parser1",
      "type": "@n8n/n8n-nodes-langchain.outputParserAutofixing",
      "position": [
        700,
        500
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "3ca64a90-a7f9-4121-ad57-5c1c2c0af8f0",
      "name": "Structured Output Parser3",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "notes": "This is the JSON Schema template for the output.",
      "position": [
        360,
        700
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "0319df56-5ca3-47d1-b0a8-7b2759f1c296",
      "name": "Config1",
      "type": "n8n-nodes-base.code",
      "position": [
        -140,
        280
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "327ef64c-e355-47ff-8b88-38a33250ab58",
      "name": "Think1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        100,
        280
      ],
      "parameters": {},
      "retryOnFail": true,
      "typeVersion": 1.8,
      "alwaysOutputData": true
    },
    {
      "id": "827d641d-fc46-4e52-b61e-a84e1c05de5e",
      "name": "Act1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        600,
        280
      ],
      "parameters": {},
      "executeOnce": false,
      "retryOnFail": true,
      "typeVersion": 1.8,
      "alwaysOutputData": true
    },
    {
      "id": "759e5950-eff0-405e-820e-8321345702f5",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -500,
        200
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "d7c8e06c-8336-446b-b241-9cba0b2376b5",
      "name": "Config",
      "type": "n8n-nodes-base.code",
      "position": [
        -160,
        -500
      ],
      "parameters": {},
      "notesInFlow": true,
      "typeVersion": 2
    },
    {
      "id": "4ad90699-ce27-4fea-966f-1762c6b33550",
      "name": "get-weather",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -360,
        280
      ],
      "parameters": {},
      "notesInFlow": true,
      "typeVersion": 2
    },
    {
      "id": "d825d0ec-e127-4731-957d-3151e7b1c013",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        1080,
        280
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "c4f38846-6cd3-4779-bb97-b3d27ea61dcf",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        -760
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "314a95dd-b517-4365-bbe5-2ab96ad87846",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        100,
        -900
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "0c423976-dc15-4880-b996-48e60f06db77",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1040,
        -680
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "a1d0bb6a-91d1-4f07-86b5-2674791eff34",
  "connections": {
    "Act": {
      "main": [
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Act1": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Think": {
      "main": [
        [
          {
            "node": "Act",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Config": {
      "main": [
        [
          {
            "node": "Think",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Think1": {
      "main": [
        [
          {
            "node": "Act1",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Config1": {
      "main": [
        [
          {
            "node": "Think1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get-weather": {
      "main": [
        [
          {
            "node": "Config1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "start-thinking": {
      "main": [
        [
          {
            "node": "Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Task Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Act",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Task Output Parser1": {
      "ai_outputParser": [
        [
          {
            "node": "Act1",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Act",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Task Output Parser",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Act1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model3": {
      "ai_languageModel": [
        [
          {
            "node": "Task Output Parser1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model4": {
      "ai_languageModel": [
        [
          {
            "node": "Think",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model5": {
      "ai_languageModel": [
        [
          {
            "node": "Thinking output parser",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model6": {
      "ai_languageModel": [
        [
          {
            "node": "Think1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model7": {
      "ai_languageModel": [
        [
          {
            "node": "Thinking output parser1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Thinking output parser": {
      "ai_outputParser": [
        [
          {
            "node": "Think",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Thinking output parser1": {
      "ai_outputParser": [
        [
          {
            "node": "Think1",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "No Operation, do nothing": {
      "main": [
        []
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Task Output Parser",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser1": {
      "ai_outputParser": [
        [
          {
            "node": "Thinking output parser",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser2": {
      "ai_outputParser": [
        [
          {
            "node": "Task Output Parser1",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser3": {
      "ai_outputParser": [
        [
          {
            "node": "Thinking output parser1",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

🧠 A plug-and-play n8n workflow that adds LLM-powered reasoning, planning, and action to your automations — with prompts, schemas, and full agent logic included.

Source: https://n8n.io/workflows/3489/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

Transform your WhatsApp group conversations into actionable business intelligence through automated AI analysis and daily reporting. This workflow eliminates manual conversation monitoring by capturin

OpenRouter Chat, Output Parser Autofixing, Agent +6
AI & RAG

This n8n workflow template is designed to route user input to specialized agents (like a Reminder Agent, Email Agent, etc.) using a structured output from a language model. Here's a complete descripti

Output Parser Autofixing, Output Parser Structured, OpenRouter Chat +2
AI & RAG

This workflow is for automating and centralizing your bookmarking process using AI-powered tagging and seamless integration between your Android device and a self-hosted Read Deck platform (https://re

Tool Serp Api, Output Parser Autofixing, Output Parser Structured +5
AI & RAG

leads. Uses supabase, gmail, formTrigger, httpRequest. Webhook trigger; 62 nodes.

Supabase, Gmail, Form Trigger +13
AI & RAG

This workflow helps to automatically discover undocumented API endpoints by analysing JavaScript files from the website's HTML code.

Output Parser Autofixing, HTTP Request, Read Write File +5