{"record":{"id":"9b677003522b5981","repo":"n8n-io/n8n","slug":"assistant-sdk-error-remaining-substring-0-500","errorCode":null,"errorMessage":"Assistant SDK error: ${remaining.substring(0, 500)}","messagePattern":"Assistant SDK error: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/ai-workflow-builder.ee/src/assistant/assistant-handler.ts","lineNumber":227,"sourceCode":"\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tawait this.processChunkMessages(chunk, state, writer, toolCallId, context);\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\treader.releaseLock();\n\t\t}\n\n\t\tconst remaining = buffer.trim();\n\t\tif (remaining) {\n\t\t\ttry {\n\t\t\t\tconst chunk = JSON.parse(remaining) as SdkStreamChunk;\n\t\t\t\tawait this.processChunkMessages(chunk, state, writer, toolCallId, context);\n\t\t\t} catch {\n\t\t\t\t// If the remaining buffer is not JSON, it's likely a plain-text error from the SDK.\n\t\t\t\t// Throw so callers can handle it as a proper error instead of an empty response.\n\t\t\t\tthrow new Error(`Assistant SDK error: ${remaining.substring(0, 500)}`);\n\t\t\t}\n\t\t}\n\n\t\tconst responseText = state.collectedTexts.join('\\n');\n\t\tconst summary =\n\t\t\tresponseText.length > SUMMARY_MAX_LENGTH\n\t\t\t\t? responseText.substring(0, SUMMARY_MAX_LENGTH) + '...'\n\t\t\t\t: responseText;\n\n\t\treturn {\n\t\t\tresponseText,\n\t\t\tsummary,\n\t\t\tsdkSessionId: state.sdkSessionId,\n\t\t\thasCodeDiff: state.hasCodeDiff,\n\t\t\tsuggestionIds: state.suggestionIds,\n\t\t};\n\t}\n","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/ai-workflow-builder.ee/src/assistant/assistant-handler.ts#L209-L245","documentation":"Error \"Assistant SDK error: ${remaining.substring(0, 500)}\" thrown in n8n-io/n8n.","triggerScenarios":"Thrown at packages/@n8n/ai-workflow-builder.ee/src/assistant/assistant-handler.ts:227 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}