Problem with STREAMING Response and Structured Output Parser

,

To make it short: Is there any way to use the structured output Parser together with the Streaming API cause the way I use it, it tries to Structure the Output for every snippet so to speek whcih leads to a "Max iterations (10) reached. The agent could not complete the task within the allowed number of iterations.
" error

Information on your n8n setup

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

This issue occurs because the Structured Output Parser attempts to parse each streaming chunk separately. To handle this, you could try collecting the streamed chunks first using a Function node or Code node, then parse the complete output once all chunks are received.

If you’re using OpenAI’s streaming API, consider disabling streaming temporarily when using the Structured Output Parser, or implement a buffer to accumulate chunks before parsing.

This collects all chunks and outputs the complete text when the last chunk is received. You can then feed this complete text to the Structured Output Parser.