From c44a60f9f90dbb1e10bbb9867bb2d45715dd4664 Mon Sep 17 00:00:00 2001 From: yiliang114 <1204183885@qq.com> Date: Fri, 16 Jan 2026 01:05:13 +0800 Subject: [PATCH] fix(webui): improve groupContent error detection logic - Only treat as error when error field is set OR type is 'error' with content - This avoids false positives from empty error markers - While not missing real errors that only have type='error' with text --- .../src/components/toolcalls/shared/utils.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/webui/src/components/toolcalls/shared/utils.ts b/packages/webui/src/components/toolcalls/shared/utils.ts index 986e724fe..832c7e39a 100644 --- a/packages/webui/src/components/toolcalls/shared/utils.ts +++ b/packages/webui/src/components/toolcalls/shared/utils.ts @@ -154,8 +154,10 @@ export const shouldShowToolCall = (kind: string): boolean => /** * Group tool call content by type to avoid duplicate labels - * Note: Only treats content as error if contentObj.type === 'error' - * or if contentObj.error is explicitly set (not null/undefined) + * Error detection logic: + * - If contentObj.error is set (not null/undefined), treat as error + * - If contentObj.type === 'error' AND has content (text or error), treat as error + * This avoids false positives from empty error markers while not missing real errors */ export const groupContent = (content?: ToolCallContent[]): GroupedContent => { const textOutputs: string[] = []; @@ -169,9 +171,14 @@ export const groupContent = (content?: ToolCallContent[]): GroupedContent => { } else if (item.content) { const contentObj = item.content; - // Only treat as error if type is explicitly 'error' - // or if error field has a truthy value (not null/undefined) - const hasError = contentObj.type === 'error' || contentObj.error != null; + // Determine if this is an error: + // 1. error field is explicitly set (not null/undefined) + // 2. type is 'error' AND has actual content (text or error field) + const hasErrorField = contentObj.error != null; + const isErrorType = + contentObj.type === 'error' && + (contentObj.text != null || contentObj.error != null); + const hasError = hasErrorField || isErrorType; if (hasError) { let errorMsg = '';