From c7caa1421ddeeedc20daa6198c490ab34aa9707c Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Wed, 30 Sep 2026 17:50:11 +0200 Subject: [PATCH] fix: tool HTML embeds vanish when the HTML contains entities like " (#31390) Tools that return inline HTML showed no embed at all when the HTML contained an entity such as `"` or `"`, and HTML containing `&` or `<` showed up with those turned into real characters. The chat view unescaped HTML entities in a tool's embeds, arguments and file links, which is only right for chats saved by older versions, so on current chats it changed the tool's own HTML before displaying it. Embeds, tool arguments and file links now show exactly what the tool returned, and older chats render as before. Fixes #28085 --- src/lib/components/chat/Messages/structuredOutput.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib/components/chat/Messages/structuredOutput.ts b/src/lib/components/chat/Messages/structuredOutput.ts index bca4a0ff08..f0045759fa 100644 --- a/src/lib/components/chat/Messages/structuredOutput.ts +++ b/src/lib/components/chat/Messages/structuredOutput.ts @@ -1,3 +1,5 @@ +import { encode } from 'html-entities'; + export type OutputContentPart = { type?: string; text?: unknown; @@ -228,9 +230,10 @@ function buildToolCallToken(item: OutputItem, toolOutputByCallId: Record attributes. + arguments: encode(stringifyAttribute(item.arguments ?? '')), + files: encode(stringifyAttribute(resultItem?.files)), + embeds: encode(stringifyAttribute(resultItem?.embeds)) } }; }