AI Summarization looping for no reason

Describe the problem/error/question

I’m trying to make a youtube script summarizing AI.
But the thing is after summarizing the whole content, AI keep summarizing the whole thing over and over again.

What is the error message (if any)?

There is no specific error message but the output must be shown after 6 cycles but Ai model keep goes on like the image below.

Please share your workflow(you may input youtube links with an transcript)

{
“meta”: {
“instanceId”: “558d88703fb65b2d0e44613bc35916258b0f0bf983c5d4730c00c424b77ca36a”
},
“nodes”: [
{
“parameters”: {},
“id”: “c5ef69f7-2469-407f-829c-e802e79a7f5d”,
“name”: “When clicking ‘Test workflow’”,
“type”: “n8n-nodes-base.manualTrigger”,
“typeVersion”: 1,
“position”: [
880,
660
]
},
{
“parameters”: {
“jsCode”: “function getVideoId(url) {\n // Handle youtu.be format\n if (url.includes(‘youtu.be/’)) {\n const id = url.split(‘youtu.be/’)[1].split(‘?’)[0];\n return id;\n }\n \n // Handle youtube.com format\n if (url.includes(‘YouTube’)) {\n const matches = url.match(/[?&]v=([^&#]+)/);\n return matches ? matches[1] : null;\n }\n \n return null;\n}\n\nasync function processSingle(item, index) {\n const url = item?.json?.url || item?.url;\n const lang = item?.json?.language || ‘ko’; // Default to Korean if not specified\n \n if (!url) {\n return {\n json: {\n error: No URL found in item ${index},\n inputReceived: JSON.stringify(item)\n }\n };\n }\n\n try {\n const videoId = getVideoId(url);\n if (!videoId) {\n return {\n json: {\n error: ‘Could not extract video ID from URL’,\n url: url\n }\n };\n }\n\n return {\n json: {\n videoId,\n language: lang,\n pageUrl: https://www.youtube.com/watch?v=${videoId},\n headers: {\n ‘User-Agent’: ‘Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36’,\n ‘Accept-Language’: ${lang},en-US;q=0.9 // Prioritize the requested language\n }\n }\n };\n } catch (error) {\n return {\n json: {\n error: error.message,\n errorDetail: error.toString(),\n url,\n inputItem: JSON.stringify(item)\n }\n };\n }\n}\n\n// Process all items\nconst results = await Promise.all(items.map(processSingle));\nreturn results;”
},
“id”: “dee8e177-9dcc-42d8-858b-ae1bd8050285”,
“name”: “Extract Video ID”,
“type”: “n8n-nodes-base.code”,
“typeVersion”: 2,
“position”: [
1080,
660
]
},
{
“parameters”: {
“url”: “={{ $json.pageUrl }}”,
“sendHeaders”: true,
“headerParameters”: {
“parameters”: [
{
“name”: “User-Agent”,
“value”: “={{ $json.headers["User-Agent"] }}”
},
{
“name”: “Accept-Language”,
“value”: “={{ $json.headers["Accept-Language"] }}”
}
]
},
“options”: {}
},
“id”: “f1cc5069-2a56-41cf-bf63-97b1d6f755e2”,
“name”: “Fetch YouTube Page”,
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 4.2,
“position”: [
1280,
660
]
},
{
“parameters”: {
“jsCode”: “for (const item of items) {\n const html = item.json.data;\n const targetLang = item.json.language || ‘ko’; // Default to Korean\n \n // Extract the transcript data\n const transcriptMatch = html.match(/"captionTracks":\[(.?)\]/);\n if (!transcriptMatch) {\n item.json = { error: ‘No transcript data found’ };\n continue;\n }\n\n // Parse the caption tracks\n const captionTracks = JSON.parse([${transcriptMatch[1]}]);\n \n // Look for the requested language\n const targetTrack = captionTracks.find(track => \n track.languageCode === targetLang || \n track.vssId?.includes(.${targetLang})\n );\n\n if (!targetTrack) {\n // If target language not found, try auto-generated version\n const autoTrack = captionTracks.find(track => \n track.kind === "asr" && \n (track.languageCode === targetLang || track.vssId?.includes(.${targetLang}))\n );\n \n if (!autoTrack) {\n item.json = { \n error: No ${targetLang} transcript found (neither manual nor auto-generated),\n availableLanguages: captionTracks.map(track => ({\n code: track.languageCode,\n kind: track.kind,\n name: track.name?.simpleText\n }))\n };\n continue;\n }\n \n item.json.transcriptUrl = autoTrack.baseUrl;\n } else {\n item.json.transcriptUrl = targetTrack.baseUrl;\n }\n}\n\nreturn items;"
},
“id”: “bd23b4bc-414d-451d-bce7-05b447780a5b”,
“name”: “Extract Transcript URL”,
“type”: “n8n-nodes-base.code”,
“typeVersion”: 2,
“position”: [
1460,
660
]
},
{
“parameters”: {
“url”: “={{ $json.transcriptUrl }}”,
“sendHeaders”: true,
“headerParameters”: {
“parameters”: [
{
“name”: “User-Agent”,
“value”: “={{ $(‘Extract Video ID’).item.json.headers["User-Agent"] }}”
},
{
“name”: “Accept-Language”,
“value”: “={{ $(‘Extract Video ID’).item.json.headers["Accept-Language"] }}”
}
]
},
“options”: {}
},
“id”: “ce9ae899-21bf-48a3-8062-a0819ac16730”,
“name”: “Fetch Transcript”,
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 4.2,
“position”: [
1660,
660
]
},
{
“parameters”: {
“jsCode”: "for (const item of items) {\n const xml = item.json.data;\n \n // Parse the XML transcript\n const lines = xml.match(/<text[^>]
>(.?)<\/text>/g) || [];\n const transcript = lines.map(line => {\n // Decode HTML entities and remove XML tags\n const text = line\n .replace(/<[^>]>/g, ‘’)\n .replace(/"/g, ‘"’)\n .replace(/&/g, ‘&’)\n .replace(/</g, ‘<’)\n .replace(/>/g, ‘>’)\n .replace(/'/g, "‘")\n .trim();\n return text;\n }).join(’\n’); // Join with newlines for better Korean text readability\n\n item.json = {\n transcript,\n videoId: item.json.videoId,\n language: item.json.language\n };\n}\n\nreturn items;”
},
“id”: “11f64229-6625-4a1d-bcef-9528fb9e44de”,
“name”: “Format Transcript”,
“type”: “n8n-nodes-base.code”,
“typeVersion”: 2,
“position”: [
1860,
660
]
},
{
“parameters”: {
“model”: “ko-gemma-2-9b-it.Q5_1:latest”,
“options”: {}
},
“id”: “5f4a18b7-57b5-4875-ad70-bcb5c0894009”,
“name”: “Ollama Chat Model”,
“type”: “@n8n/n8n-nodes-langchain.lmChatOllama”,
“typeVersion”: 1,
“position”: [
1980,
920
],
“credentials”: {
“ollamaApi”: {
“id”: “NaLHnrhgcj1IbPEm”,
“name”: “Ollama account”
}
}
},
{
“parameters”: {
“options”: {}
},
“id”: “a07b8c06-0c87-4c38-afe4-ed0f9d05e311”,
“name”: “Default Data Loader”,
“type”: “@n8n/n8n-nodes-langchain.documentDefaultDataLoader”,
“position”: [
2100,
880
],
“typeVersion”: 1
},
{
“parameters”: {
“options”: {}
},
“id”: “aba63e5e-8221-41b9-9310-c341635247d1”,
“name”: “Recursive Character Text Splitter”,
“type”: “@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter”,
“position”: [
2180,
1060
],
“typeVersion”: 1
},
{
“parameters”: {
“operationMode”: “documentLoader”,
“options”: {}
},
“id”: “29686569-2112-483b-afcf-ffc898b6a391”,
“name”: “Summarization Chain”,
“type”: “@n8n/n8n-nodes-langchain.chainSummarization”,
“position”: [
2060,
660
],
“typeVersion”: 2
}
],
“connections”: {
“When clicking ‘Test workflow’”: {
“main”: [
[
{
“node”: “Extract Video ID”,
“type”: “main”,
“index”: 0
}
]
]
},
“Extract Video ID”: {
“main”: [
[
{
“node”: “Fetch YouTube Page”,
“type”: “main”,
“index”: 0
}
]
]
},
“Fetch YouTube Page”: {
“main”: [
[
{
“node”: “Extract Transcript URL”,
“type”: “main”,
“index”: 0
}
]
]
},
“Extract Transcript URL”: {
“main”: [
[
{
“node”: “Fetch Transcript”,
“type”: “main”,
“index”: 0
}
]
]
},
“Fetch Transcript”: {
“main”: [
[
{
“node”: “Format Transcript”,
“type”: “main”,
“index”: 0
}
]
]
},
“Format Transcript”: {
“main”: [
[
{
“node”: “Summarization Chain”,
“type”: “main”,
“index”: 0
}
]
]
},
“Ollama Chat Model”: {
“ai_languageModel”: [
[
{
“node”: “Summarization Chain”,
“type”: “ai_languageModel”,
“index”: 0
}
]
]
},
“Default Data Loader”: {
“ai_document”: [
[
{
“node”: “Summarization Chain”,
“type”: “ai_document”,
“index”: 0
}
]
]
},
“Recursive Character Text Splitter”: {
“ai_textSplitter”: [
[
{
“node”: “Default Data Loader”,
“type”: “ai_textSplitter”,
“index”: 0
}
]
]
}
},
“pinData”: {
“When clicking ‘Test workflow’”: [
{
“url”: “Youtube Link”,
“language”: “ko”
}
]
}
}

Share the output returned by the last node

As shown before, the output doesn’t come out from the summarization.
Ai repeats the whole thing.

Information on your n8n setup

  • I just downloaded n8n on my computer so it must be the latest version
  • I use ollama model which is fine tuned and was on the huggingface

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hello, have you looked at the “max Iteration Option”?

Within the Agent Node?

Actually I didn’t.
Thanks. I’ll search for it!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.