diff --git a/components/chat-message-display.tsx b/components/chat-message-display.tsx index 1429c31..81c80e7 100644 --- a/components/chat-message-display.tsx +++ b/components/chat-message-display.tsx @@ -451,11 +451,24 @@ export function ChatMessageDisplay({ Complete )} - {state === "output-error" && ( - - Error - - )} + {state === "output-error" && + (() => { + // Check if this is a truncation (incomplete XML) vs real error + const isTruncated = + (toolName === "display_diagram" || + toolName === "append_diagram") && + (!input?.xml || + !input.xml.includes("")) + return isTruncated ? ( + + Truncated + + ) : ( + + Error + + ) + })()} {input && Object.keys(input).length > 0 && ( )} - {output && state === "output-error" && ( - - {output} - - )} + {output && + state === "output-error" && + (() => { + const isTruncated = + (toolName === "display_diagram" || + toolName === "append_diagram") && + (!input?.xml || !input.xml.includes("")) + return ( + + {isTruncated + ? "Output truncated due to length limits. Try a simpler request or increase the maxOutputLength." + : output} + + ) + })()} ) } diff --git a/components/chat-panel.tsx b/components/chat-panel.tsx index 20eddee..f93450d 100644 --- a/components/chat-panel.tsx +++ b/components/chat-panel.tsx @@ -566,6 +566,12 @@ Continue from EXACTLY where you stopped.`, friendlyMessage = "Network error. Please check your connection." } + // Truncated tool input error (model output limit too low) + if (friendlyMessage.includes("toolUse.input is invalid")) { + friendlyMessage = + "Output was truncated before the diagram could be generated. Try a simpler request or increase the maxOutputLength." + } + // Translate image not supported error if (friendlyMessage.includes("image content block")) { friendlyMessage = "This model doesn't support image input."