I have a workflow where an AI Agent node classifies news articles by adding a binary boolean flag to each article object. I’m running into frequent issues with:
output being truncated (leading to malformed JSON and parse errors)
missing articles in the output (more than half), even with strict prompting
There are about 250 article objects (Title, Source, Date, Link), which doesn’t seem like an amount that would overwhelm a model. I’ve tried using different LLMs (Llama, Deepseek, Gemini), and refining prompts.
Are there better ways to structure workflows for reliably processing and merging larger arrays with LLM nodes? Is there a way to ensure all items are returned, without output truncation?
Hi @Amir_HK
quick question to clarify your setup: are you sending the entire array of 250 articles in one go to the AI Agent, or are you looping over the list and sending each article object individually?
Yes, in most cases, sending a large batch (like 250 articles) to an LLM at once will almost always lead to output truncation, parsing issues, and missing data, even with strict prompting…
You can also leverage the Output Parser feature in the AI Agent, which can help with more reliable parsing…
Additionally, there’s a Text Classifier node available, it might be worth taking a look to see if it fits your use case better…
Ultimately, working with agents and prompts is often an iterative, trial-and-error process., It’s important to test multiple approaches and pick the one that proves the most reliable for your specific workflow…
Ok thank you. I had thought the context wasn’t too high as the AI is just being asked to evaluate each article title and make a binary classification. Looping each individual item sounds very slow. I will give it a try with a batch size of 20. Much appreciated.
Hi, I’m just thinking that by combining your data into larger chunks / batches in the same context window, you would influence the outcome as compared to feeding each individual item on its own.
My idea comes from the fact on how LLM’s are trained. batch size and order can have a lot of influence.
Beside having output issues and what not, I think the results themselves will be skewed.
You should try with small batch vs individual imho
For my use case, I am presenting a list of news article titles and prompting the LLM to add a True/False parameter to each one according to a set of criteria (list of interests for the audience). It didn’t seem like an intensive task (compared to say uploading huge PDFs into a chatbot and prompting for summaries).
I tried running it in batches (10/15/20) and the accuracy definitely seems better, but I seem to hit Agent errors every few runs, or occasionally the output has extra lines with quotation marks inserted between each article. It has been quite tricky getting consistent high quality output from these Agent workflows.