{
  "schemaVersion": "flowdrome.workflow.v1",
  "id": "",
  "name": "AI · 02 — Agent (tools + memory)",
  "version": "0",
  "status": "draft",
  "nodes": [
    {
      "id": "seed",
      "type": "input.inject",
      "label": "Task",
      "category": "trigger",
      "config": {
        "contentType": "application/json",
        "payload": {
          "message": "How many units of SKU N-100 do we have in stock?",
          "sessionId": "ai-demo"
        }
      },
      "position": {
        "x": 0,
        "y": 0
      }
    },
    {
      "id": "agent",
      "type": "ai.agent",
      "label": "Agent",
      "category": "ai",
      "config": {
        "provider": "ollama",
        "baseUrl": "",
        "apiKey": "",
        "model": "qwen2.5:1.5b",
        "models": [],
        "system": "You are a warehouse assistant. For ANY stock or inventory question you MUST call the check_inventory tool — you have no other way to know stock levels. Answer in one short sentence.",
        "outputFormat": "text",
        "temperature": 0.2,
        "maxTokens": 256,
        "maxIterations": 4,
        "historyLimit": 20,
        "memoryBackend": "file",
        "memoryDir": "./ai-demo-memory",
        "sessionKey": "{{ input.sessionId }}",
        "approval": "off",
        "tools": [
          {
            "type": "function",
            "name": "check_inventory",
            "description": "Look up how many units of a SKU are in stock. Call with the SKU code, e.g. 'N-100'.",
            "parameters": {
              "type": "object",
              "properties": {
                "sku": {
                  "type": "string"
                }
              },
              "required": [
                "sku"
              ]
            },
            "code": "var db = { 'N-100': 42, 'N-200': 7, 'N-300': 0 }; var k = String(args.sku || '').toUpperCase().trim(); return { sku: k, unitsInStock: db[k] === undefined ? 'unknown SKU' : db[k] };"
          }
        ]
      },
      "position": {
        "x": 530,
        "y": 0
      },
      "attachments": {
        "model": "llm",
        "memory": "mem"
      }
    },
    {
      "id": "llm",
      "type": "ai.model",
      "label": "Ollama (local)",
      "category": "ai",
      "config": {
        "provider": "ollama",
        "baseUrl": "",
        "apiKey": "",
        "model": "qwen2.5:1.5b",
        "models": [],
        "temperature": 0.2,
        "maxTokens": 512
      },
      "position": {
        "x": 530,
        "y": 222
      }
    },
    {
      "id": "mem",
      "type": "ai.memory",
      "label": "File memory",
      "category": "ai",
      "config": {
        "memoryBackend": "file",
        "memoryDir": "./ai-demo-memory",
        "sessionKey": "{{ input.sessionId }}",
        "historyLimit": 20
      },
      "position": {
        "x": 574,
        "y": 262
      }
    },
    {
      "id": "out",
      "type": "utility.console",
      "label": "Result",
      "category": "utility",
      "config": {
        "message": "Agent: {{ $json.text }}  (loop iterations: {{ $json.iterations }})"
      },
      "position": {
        "x": 1060,
        "y": 0
      }
    }
  ],
  "edges": [
    {
      "id": "e0",
      "sourceNodeId": "seed",
      "sourcePort": "output",
      "targetNodeId": "agent",
      "targetPort": "input"
    },
    {
      "id": "e1",
      "sourceNodeId": "agent",
      "sourcePort": "output",
      "targetNodeId": "out",
      "targetPort": "input"
    }
  ],
  "triggers": [
    {
      "id": "t0",
      "nodeId": "seed"
    }
  ],
  "meta": {
    "snippets": [],
    "source": "template-gallery",
    "description": "An agent that THINKS with a wired ◈ Model, REMEMBERS with a wired ◈ Memory (./ai-demo-memory), and ACTS with a warehouse-lookup tool — it CANNOT know the stock count without calling it (N-100 → 42). Run it twice and it remembers the conversation."
  }
}