Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

Refactor processStreamChunk function: Improve error message handling

Salman-Ahamede73b64a60c0d
diff --git a/packages/app/src/react/features/ai-chat/utils/stream.utils.ts b/packages/app/src/react/features/ai-chat/utils/stream.utils.ts
index 009fc79c..6bea308b 100644
--- a/packages/app/src/react/features/ai-chat/utils/stream.utils.ts
+++ b/packages/app/src/react/features/ai-chat/utils/stream.utils.ts
@@ -363,6 +363,9 @@ export class ThinkingMessageManager {
* @returns Processed information
*/
export const processStreamChunk = (chunk: IStreamChunk) => {
+ // When isError is true, the error message is in the content field
+ const errorMessage = chunk.error || (chunk.isError ? chunk.content : null);
+
return {
hasContent: Boolean(chunk.content && chunk.content.trim() !== ''),
hasDebug: Boolean(chunk.debug),
@@ -372,7 +375,7 @@ export const processStreamChunk = (chunk: IStreamChunk) => {
functionName: chunk.function || chunk.function_call?.name || null,
statusMessage: chunk.status_message || null,
content: chunk.content || '',
- error: chunk.error || null,
+ error: errorMessage || null,
};
};