This workflow follows the Agent → OpenAI 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 →
{
"name": "pass@k",
"nodes": [
{
"parameters": {
"promptType": "define",
"text": "={{ $json.output }}",
"options": {
"systemMessage": "You are a SpinalHDL RTL designer that only writes code using correct Spinalhdl syntax.Enclose your code with [BEGIN] and [DONE].Only output the code snippet and do NOT output anything else.use follow pattern:\n```\nimport spinal.core._\nimport spinal.lib._\n\n// Hardware definition\ncase class TopModule() extends Component {\n \n}\n\nobject TopMain {\n def main(args: Array[String]) {\n SpinalVerilog(new TopModule)\n }\n}\n\n```"
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 2,
"position": [
-816,
-160
],
"id": "e80fe082-edb5-4d26-9ab9-04c981fb6fba",
"name": "AI Agent",
"alwaysOutputData": false
},
{
"parameters": {
"operation": "toText",
"sourceProperty": "output",
"binaryPropertyName": "=data",
"options": {
"fileName": "={{ $('Read Prompt Files').all()[$runIndex].json.fileName.replace(/prompt\\.txt$/, 'sample0'+($itemIndex+1)+'.scala') }}"
}
},
"type": "n8n-nodes-base.convertToFile",
"typeVersion": 1.1,
"position": [
-336,
-192
],
"id": "e2768d1f-ac5b-4be0-8e7f-2afff0b446e8",
"name": "Convert to File"
},
{
"parameters": {
"content": "## \u8f93\u5165\u83b7\u53d6\u4e0e\u5904\u7406 ",
"height": 404,
"width": 952
},
"type": "n8n-nodes-base.stickyNote",
"position": [
-2544,
-240
],
"typeVersion": 1,
"id": "19d47066-2d7c-42da-a753-57c150e3c1f4",
"name": "Sticky Note"
},
{
"parameters": {
"options": {}
},
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 3,
"position": [
-1712,
-48
],
"id": "fa970be3-6197-4f1c-9881-633d68cbb4ba",
"name": "Loop Over Items"
},
{
"parameters": {
"executeOnce": false,
"command": "=mkdir -p /files/output-test/{{$('Read Prompt Files').item.json.fileName.slice(0,-11)}}"
},
"type": "n8n-nodes-base.executeCommand",
"typeVersion": 1,
"position": [
-2224,
-160
],
"id": "9ba60180-f842-4419-99a3-c68698ce9d8a",
"name": "create fold",
"alwaysOutputData": true
},
{
"parameters": {
"fileSelector": "/files/dataset_spec-to-spinalhdl/Prob*.txt",
"options": {}
},
"type": "n8n-nodes-base.readWriteFile",
"typeVersion": 1,
"position": [
-2400,
-64
],
"id": "9bde9a9f-fb08-47d4-a68f-a8680309c69f",
"name": "Read Prompt Files"
},
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
-2544,
-64
],
"id": "b6fc62b4-985e-4f3c-bf66-e86f759e8572",
"name": "Execute workflow"
},
{
"parameters": {
"operation": "text",
"options": {}
},
"type": "n8n-nodes-base.extractFromFile",
"typeVersion": 1,
"position": [
-1904,
-48
],
"id": "3bed9b23-df10-4414-a3ce-d6fb70e097f5",
"name": "Extract Prompt from File"
},
{
"parameters": {
"operation": "toText",
"sourceProperty": "=output",
"binaryPropertyName": "=data",
"options": {
"fileName": "={{ $('Read Prompt Files').all()[$runIndex].json.fileName.replace(/prompt\\.txt$/, 'sample0'+($itemIndex+1)+'-sv-generate.log') }}"
}
},
"type": "n8n-nodes-base.convertToFile",
"typeVersion": 1.1,
"position": [
-464,
-32
],
"id": "8b1a2dc5-7940-47eb-a157-78368b5a3257",
"name": "Edit log"
},
{
"parameters": {},
"type": "n8n-nodes-base.merge",
"typeVersion": 3.2,
"position": [
-64,
-48
],
"id": "674561cd-aa72-4b77-aff8-41b4b4028793",
"name": "Merge"
},
{
"parameters": {},
"type": "n8n-nodes-base.merge",
"typeVersion": 3.2,
"position": [
-2064,
-48
],
"id": "93f72d2b-1a6c-48ea-b9a3-e4ef2a7e928f",
"name": "Merge1"
},
{
"parameters": {
"operation": "write",
"fileName": "=/files/output-test/{{$('Read Prompt Files').all()[$runIndex].json.fileName.slice(0,-11)}}/{{$('Edit log').item.binary.data.fileName}}",
"dataPropertyName": "=data",
"options": {
"append": false
}
},
"type": "n8n-nodes-base.readWriteFile",
"typeVersion": 1,
"position": [
-320,
-16
],
"id": "f2c3b7c6-88f8-4dd9-bb04-35e1f626101f",
"name": "Write Log Files to Disk1"
},
{
"parameters": {
"operation": "write",
"fileName": "=/files/output-test/{{$('Read Prompt Files').all()[$runIndex].json.fileName.slice(0,-11)}}/{{$('Convert to File').item.binary.data.fileName}}",
"dataPropertyName": "=data",
"options": {
"append": false
}
},
"type": "n8n-nodes-base.readWriteFile",
"typeVersion": 1,
"position": [
-176,
-192
],
"id": "d9e72f40-c67e-4789-bda5-02885d06b042",
"name": "Write Scala Files to Disk"
},
{
"parameters": {
"jsCode": "for (const item of $input.all()) {\n const text = item.json.output || '';\n \n // \u5c1d\u8bd5\u5339\u914d [BEGIN] \u548c [DONE] \u4e4b\u95f4\u7684\u5185\u5bb9\n // const beginDoneRegex = /\\[BEGIN\\]\\s*([\\s\\S]*?)\\s*\\[DONE\\]/;\n // const beginDoneMatch = text.match(beginDoneRegex);\n \n // if (beginDoneMatch) {\n // // \u6210\u529f\u5339\u914d\uff1a\u63d0\u53d6\u4e2d\u95f4\u5185\u5bb9\u5e76\u53bb\u9664\u9996\u5c3e\u7a7a\u767d\n // item.json.output = beginDoneMatch[1].trim();\n // } else {\n // \u5339\u914d\u5931\u8d25\uff1a\u5c1d\u8bd5\u5339\u914d SpinalHDL \u5b8c\u6574\u4ee3\u7801\u5757\n const spinalRegex = /(import spinal\\.core\\._[\\s\\S]*?object TopMain\\s*\\{[\\s\\S]*?\\}\\s*\\})/;\n const spinalMatch = text.match(spinalRegex);\n \n if (spinalMatch) {\n // \u6210\u529f\u5339\u914d\uff1a\u8fd4\u56de\u5305\u542b\u6807\u8bb0\u7684\u5b8c\u6574\u4ee3\u7801\u5757\n item.json.output = spinalMatch[1].trim();\n } else {\n // \u53cc\u91cd\u5339\u914d\u5931\u8d25\uff1a\u8fd4\u56de\u7a7a\u5b57\u7b26\u4e32\n item.json.output = '';\n }\n // }\n}\n\nreturn $input.all();"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-464,
-192
],
"id": "fdb1245d-4159-402e-880b-8e8cacf40855",
"name": "Code"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "8c8d3eef-b4d8-4d82-aeb1-4bce092e7eb7",
"name": "=output",
"value": "={{ $json.data +\"Must choose context7 tool.Use context7.\"}}",
"type": "string"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
-1296,
-176
],
"id": "f0c5bc62-0f6f-418b-ac02-8c2a6e05bbcf",
"name": "Edit Prompt1"
},
{
"parameters": {
"descriptionType": "manual",
"toolDescription": "Use MCP client.Use context7",
"connectionType": "sse",
"operation": "executeTool",
"toolName": "=get-library-docs",
"toolParameters": "={\n\"context7CompatibleLibraryID\":\"/spinalhdl/spinaldoc-rtd\",\n\"topic\":\"{{ $('Merge2').all().last().json.output }}\",\n\"tokens\":\"10000\"\n}"
},
"type": "n8n-nodes-mcp.mcpClientTool",
"typeVersion": 1,
"position": [
-784,
48
],
"id": "d96e1880-9767-476c-9dca-3cf99ce8f0f1",
"name": "MCP Client1",
"credentials": {
"mcpClientSseApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"connectionType": "sse"
},
"type": "n8n-nodes-mcp.mcpClientTool",
"typeVersion": 1,
"position": [
-656,
48
],
"id": "62de4d8c-1870-45fa-8e45-81bb2519961f",
"name": "MCP Client",
"credentials": {
"mcpClientSseApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"content": "## Generation LLM\u53caMCP\u8c03\u7528\n",
"height": 420,
"width": 964,
"color": 4
},
"type": "n8n-nodes-base.stickyNote",
"position": [
-1520,
-240
],
"typeVersion": 1,
"id": "3f544b7c-775b-4954-90c2-cb289c445ccb",
"name": "Sticky Note1"
},
{
"parameters": {
"content": "## \u4ee3\u7801\u53calog\u4fdd\u5b58\n",
"height": 388,
"width": 640,
"color": 3
},
"type": "n8n-nodes-base.stickyNote",
"position": [
-528,
-240
],
"typeVersion": 1,
"id": "122f30c2-c16f-4377-a4cc-bf2ef8cc662a",
"name": "Sticky Note2"
},
{
"parameters": {
"model": {
"__rl": true,
"value": "deepseek-ai/DeepSeek-V3.1-Terminus",
"mode": "list",
"cachedResultName": "deepseek-ai/DeepSeek-V3.1-Terminus"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [
-944,
48
],
"id": "331f3247-ae73-4453-854b-02fa6d3d8325",
"name": "OpenAI Chat Model",
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"promptType": "define",
"text": "={{ $json.data }}",
"options": {
"systemMessage": "You are a spinalhdl prompt word summary assistant that only output four spinalhdl topic words based on user message,separated by commas for all topic words"
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 2,
"position": [
-1440,
240
],
"id": "6607e3c6-d47d-43c3-9468-bafdb8bea169",
"name": "AI Agent1"
},
{
"parameters": {
"model": {
"__rl": true,
"value": "Qwen/Qwen3-30B-A3B-Instruct-2507",
"mode": "list",
"cachedResultName": "Qwen/Qwen3-30B-A3B-Instruct-2507"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [
-1440,
400
],
"id": "b34614d3-ec6d-46ce-a3b3-5d0fb5cc6145",
"name": "OpenAI Chat Model1",
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "//return Array(5).fill({});\n\n// \u83b7\u53d6\u4e0a\u4e00\u4e2a\u8282\u70b9\u7684\u6240\u6709\u6570\u636e\nconst previousData = $input.all();\n\n// \u5982\u679c\u4e0a\u4e00\u4e2a\u8282\u70b9\u6709\u6570\u636e\uff0c\u590d\u52363\u6b21\nif (previousData && previousData.length > 0) {\n const result = [];\n for (let i = 0; i < 1; i++) {\n // \u590d\u5236\u6570\u636e\u5e76\u6dfb\u52a0\u5faa\u73af\u7d22\u5f15\u4fe1\u606f\n previousData.forEach(item => {\n result.push({\n json: {\n ...item.json, // \u4fdd\u7559\u539f\u59cb\u6570\u636e\n iteration: i + 1, // \u6dfb\u52a0\u8fed\u4ee3\u6b21\u6570\u6807\u8bc6\n runIndex: $runIndex // \u6dfb\u52a0\u8fd0\u884c\u7d22\u5f15\n }\n });\n });\n }\n return result;\n} else {\n // \u5982\u679c\u6ca1\u6709\u4e0a\u4e00\u4e2a\u8282\u70b9\u7684\u6570\u636e\uff0c\u8fd4\u56de\u7a7a\u6570\u7ec4\n return [];\n}\n\n"
},
"id": "b5d6a10b-b125-49bd-bdae-2c9992b2908c",
"name": "\u63a7\u5236\u91c7\u6837\u6b21\u6570",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-1472,
-176
]
},
{
"parameters": {},
"type": "n8n-nodes-base.merge",
"typeVersion": 3.2,
"position": [
-1120,
-160
],
"id": "6c0b7036-dd66-499c-a5db-0f745b47e1a4",
"name": "Merge2"
},
{
"parameters": {
"jsCode": "// \u83b7\u53d6\u4e0a\u4e00\u4e2a\u8282\u70b9\u7684\u6240\u6709\u6570\u636e\nconst previousData = $input.all();\n\n// \u5982\u679c\u4e0a\u4e00\u4e2a\u8282\u70b9\u6709\u6570\u636e\uff0c\u63d0\u53d6\u9664\u6700\u540e\u4e00\u4e2a\u4e4b\u5916\u7684\u6240\u6709\u6570\u636e\nif (previousData && previousData.length > 0) {\n const result = [];\n \n // \u5904\u7406\u9664\u6700\u540e\u4e00\u4e2a\u4e4b\u5916\u7684\u6240\u6709\u6570\u636e\u9879\n for (let i = 0; i < previousData.length - 1; i++) {\n result.push({\n json: {\n ...previousData[i].json, // \u4fdd\u7559\u539f\u59cb\u6570\u636e\n originalIndex: i, // \u6dfb\u52a0\u539f\u59cb\u7d22\u5f15\u6807\u8bc6\n runIndex: $runIndex // \u6dfb\u52a0\u8fd0\u884c\u7d22\u5f15\n }\n });\n }\n \n return result;\n} else {\n // \u5982\u679c\u6ca1\u6709\u4e0a\u4e00\u4e2a\u8282\u70b9\u7684\u6570\u636e\uff0c\u8fd4\u56de\u7a7a\u6570\u7ec4\n return [];\n}"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-976,
-160
],
"id": "9f38eeef-a800-4058-aa30-bcc5cf6b0d48",
"name": "Code in JavaScript"
},
{
"parameters": {
"content": "## \u63d0\u793a\u8bcd\u89e3\u6790\n",
"height": 340,
"width": 484,
"color": 6
},
"type": "n8n-nodes-base.stickyNote",
"position": [
-1520,
192
],
"typeVersion": 1,
"id": "f11734db-2045-4873-9b1f-7d208f785da1",
"name": "Sticky Note3"
},
{
"parameters": {
"model": "deepseek/deepseek-v3.1-terminus",
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
"typeVersion": 1,
"position": [
-896,
208
],
"id": "2f44d25e-a5db-48f7-81d4-f9df5605f24a",
"name": "OpenRouter Chat Model",
"credentials": {
"openRouterApi": {
"name": "<your credential>"
}
}
}
],
"connections": {
"AI Agent": {
"main": [
[
{
"node": "Edit log",
"type": "main",
"index": 0
},
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"Convert to File": {
"main": [
[
{
"node": "Write Scala Files to Disk",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items": {
"main": [
[],
[
{
"node": "\u63a7\u5236\u91c7\u6837\u6b21\u6570",
"type": "main",
"index": 0
},
{
"node": "AI Agent1",
"type": "main",
"index": 0
}
]
]
},
"create fold": {
"main": [
[
{
"node": "Merge1",
"type": "main",
"index": 0
}
]
]
},
"Read Prompt Files": {
"main": [
[
{
"node": "create fold",
"type": "main",
"index": 0
},
{
"node": "Merge1",
"type": "main",
"index": 1
}
]
]
},
"Execute workflow": {
"main": [
[
{
"node": "Read Prompt Files",
"type": "main",
"index": 0
}
]
]
},
"Extract Prompt from File": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Edit log": {
"main": [
[
{
"node": "Write Log Files to Disk1",
"type": "main",
"index": 0
}
]
]
},
"Merge": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Merge1": {
"main": [
[
{
"node": "Extract Prompt from File",
"type": "main",
"index": 0
}
]
]
},
"Write Log Files to Disk1": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
}
]
]
},
"Write Scala Files to Disk": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
},
"Code": {
"main": [
[
{
"node": "Convert to File",
"type": "main",
"index": 0
}
]
]
},
"Edit Prompt1": {
"main": [
[
{
"node": "Merge2",
"type": "main",
"index": 0
}
]
]
},
"MCP Client1": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"MCP Client": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[]
]
},
"AI Agent1": {
"main": [
[
{
"node": "Merge2",
"type": "main",
"index": 1
}
]
]
},
"OpenAI Chat Model1": {
"ai_languageModel": [
[
{
"node": "AI Agent1",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"\u63a7\u5236\u91c7\u6837\u6b21\u6570": {
"main": [
[
{
"node": "Edit Prompt1",
"type": "main",
"index": 0
}
]
]
},
"Merge2": {
"main": [
[
{
"node": "Code in JavaScript",
"type": "main",
"index": 0
}
]
]
},
"Code in JavaScript": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"OpenRouter Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "b36cb968-750e-455c-b556-01d03eaba855",
"meta": {
"templateCredsSetupCompleted": true
},
"id": "cHy6j3tWsfWYcw6N",
"tags": []
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
mcpClientSseApiopenAiApiopenRouterApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
pass@k. Uses agent, executeCommand, readWriteFile, n8n-nodes-mcp. Event-driven trigger; 27 nodes.
Source: https://github.com/Yuxin-Yu/SpinalHDL-Eval/blob/12bfd202ebb1043d3eeb8b157d8f525b3b853f19/n8n/SpinalHDL-Eval-MCP.json — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
RAG CHATBOT Main. Uses telegram, telegramTrigger, lmChatOpenAi, n8n-nodes-mcp. Event-driven trigger; 87 nodes.
Sora 2 Pro Talking-Head Video Generator | AI 数字人口播视频生成(Sora 2 Pro + MiniMax TTS + FFmpeg 自动合成). Uses httpRequest, agent, lmChatOpenRouter, dataTable. Event-driven trigger; 74 nodes.
My workflow 4. Uses formTrigger, httpRequest, googleDrive, agent. Event-driven trigger; 48 nodes.
Turbo Videogen. Uses lmChatOpenRouter, agent, httpRequest, formTrigger. Event-driven trigger; 41 nodes.
Template Nodes Example. Uses CUSTOM, formTrigger, executeWorkflowTrigger, chatTrigger. Event-driven trigger; 70 nodes.