{
  "id": "2d9f4b6a-1e44-4a71-8d52-b1c6f7a9d404",
  "name": "agent_smoke_e2e",
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "nodes": [
    {
      "id": "ManualTriggerSmoke",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        220,
        320
      ],
      "parameters": {}
    },
    {
      "id": "BuildSmokeInput",
      "name": "Build Smoke Input",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        460,
        320
      ],
      "parameters": {
        "jsCode": "const now = new Date().toISOString();\nconst sessionId = `smoke-${Date.now()}`;\nreturn [{\n  json: {\n    session_id: sessionId,\n    question: 'smoke: ping',\n    user_id: 'smoke-check',\n    token: $env.AGENT_WORKFLOW_TOKEN || '',\n    run_at: now\n  }\n}];"
      }
    },
    {
      "id": "CallAgentQuery",
      "name": "HTTP: agent_query_main",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        700,
        320
      ],
      "continueOnFail": true,
      "parameters": {
        "method": "POST",
        "url": "={{ (($env.INTERNAL_WEBHOOK_BASE_URL || 'http://127.0.0.1:5678').replace(/\\/?$/, '')) + '/webhook/' + ($env.N8N_AGENT_QUERY_WEBHOOK_PATH || 'agent-query') }}",
        "responseFormat": "string",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { session_id: $json.session_id, user_id: $json.user_id, question: $json.question } }}",
        "options": {
          "timeout": 120000
        }
      }
    },
    {
      "id": "AssertAgentResponse",
      "name": "Assert Agent Response",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        940,
        320
      ],
      "parameters": {
        "jsCode": "if ($json.error) {\n  const message = String($json.error.message ?? $json.error ?? 'unknown upstream error');\n  throw new Error('agent_query_main call failed: ' + message);\n}\nconst rawBody = $json.body ?? $json.data ?? $json.response ?? $json;\nlet payload = rawBody;\nif (typeof rawBody === 'string') {\n  const text = rawBody.trim();\n  if (!text) throw new Error('agent_query_main returned empty body');\n  try {\n    payload = JSON.parse(text);\n  } catch {\n    throw new Error('agent_query_main returned non-JSON body: ' + text.slice(0, 300));\n  }\n}\nif (!payload || typeof payload !== 'object') {\n  throw new Error('agent_query_main returned unexpected payload type');\n}\nconst answer = String(payload.answer ?? '').trim();\nif (!answer) {\n  throw new Error('agent_query_main returned payload without answer');\n}\nreturn [{\n  json: {\n    session_id: String(payload.session_id ?? $json.session_id ?? ''),\n    answer\n  }\n}];"
      }
    }
  ],
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Build Smoke Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Smoke Input": {
      "main": [
        [
          {
            "node": "HTTP: agent_query_main",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP: agent_query_main": {
      "main": [
        [
          {
            "node": "Assert Agent Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Assert Agent Response": {
      "main": [
        []
      ]
    }
  },
  "versionId": "00000000-0000-0000-0000-000000000004",
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": [
    {
      "name": "agent"
    },
    {
      "name": "smoke"
    }
  ]
}