{
  "name": "AI agent that updates its own rules to modify behavior",
  "nodes": [
    {
      "id": "70bedb4b-6fe6-4cf0-86c5-e3c8e78fa256",
      "name": "Ultimate Assistant1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        480,
        100
      ]
    },
    {
      "id": "53fc82b4-81d2-4e4d-8bdb-fb253a513626",
      "name": "Chat History1",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        540,
        360
      ]
    },
    {
      "id": "a7108939-61f7-40f1-8c35-8ed7410fc45a",
      "name": "Anthropic Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        360,
        360
      ]
    },
    {
      "id": "6765ccef-d5ad-4040-9378-67fe0019e7c7",
      "name": "Get rules from database",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -180,
        -20
      ]
    },
    {
      "id": "33e63152-923a-4b61-a9b1-71b8c43ba90d",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        260,
        100
      ]
    },
    {
      "id": "e0343829-da12-4ed7-a610-8353168a2562",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        40,
        -20
      ]
    },
    {
      "id": "cae47efc-4063-412a-bdc4-366f1cdb5308",
      "name": "Insert rule into database",
      "type": "n8n-nodes-base.postgresTool",
      "position": [
        920,
        340
      ]
    },
    {
      "id": "edda3371-1237-405e-a76e-bda1e0253b80",
      "name": "Execute query on rule database",
      "type": "n8n-nodes-base.postgresTool",
      "position": [
        1100,
        340
      ]
    },
    {
      "id": "f5348ce3-3600-4dab-a784-6455fb9f53f2",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -460,
        120
      ]
    },
    {
      "id": "e154a1e8-0e6f-4e04-b97a-803ec33908ac",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1100,
        360
      ],
      "parameters": {
        "width": 1000,
        "height": 760,
        "content": "## Video walkthrough\n\n@[youtube](OwIFK-r-NtQ)\nhttps://www.youtube.com/watch?v=OwIFK-r-NtQ\n\n## Summary of agent\nThis agent can write and rewrite its own rules, allowing you to mold its behavior. It rec"
      }
    },
    {
      "id": "1adbc807-44ce-4c35-800f-5dc0092e0aad",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        60,
        580
      ],
      "parameters": {
        "width": 1240,
        "height": 540,
        "content": "## Prefer Google Sheets? Here are nodes to replace Postgres"
      }
    },
    {
      "id": "e6f9a9c7-a498-46b0-88ac-ef693288ec18",
      "name": "Get rules from sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        140,
        680
      ]
    },
    {
      "id": "728c29e0-bd0f-4237-823b-1ca01de880ef",
      "name": "Add rule to sheet",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        400,
        700
      ]
    },
    {
      "id": "41c75ff2-cbab-4ec7-b5ff-858d5abbecb4",
      "name": "Update rule in sheet",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        580,
        700
      ]
    },
    {
      "id": "6fd802ea-84ae-49bd-8e56-f966509a21e8",
      "name": "Delete rule in sheet",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        720,
        700
      ]
    }
  ],
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Ultimate Assistant1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chat History1": {
      "ai_memory": [
        [
          {
            "node": "Ultimate Assistant1",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Anthropic Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Ultimate Assistant1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Get rules from database": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert rule into database": {
      "ai_tool": [
        [
          {
            "node": "Ultimate Assistant1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          },
          {
            "node": "Get rules from database",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute query on rule database": {
      "ai_tool": [
        [
          {
            "node": "Ultimate Assistant1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}