From 5cd8986e42cb69c7b346d9c4dcf5864d1ac432f4 Mon Sep 17 00:00:00 2001 From: pionxzh Date: Sun, 10 May 2026 05:04:22 +0800 Subject: [PATCH] fix: preserve citations and content references when merging continuation nodes When thinking models produce commentary + final response messages, mergeContinuationNodes was only keeping the first message's metadata. The content_references (mapping citeturn markers to URLs) on the final message were lost, causing raw citation text in exports. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/api.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/api.ts b/src/api.ts index 9cd5cd7..99685f2 100644 --- a/src/api.ts +++ b/src/api.ts @@ -997,6 +997,22 @@ function mergeContinuationNodes(nodes: ConversationNode[]): ConversationNode[] { const separator = prevNode.message.channel !== node.message.channel ? '\n\n' : '' prevNode.message.content.parts[prevNode.message.content.parts.length - 1] += separator + node.message.content.parts[0] prevNode.message.content.parts.push(...node.message.content.parts.slice(1)) + + if (node.message.metadata) { + const prevMeta = (prevNode.message.metadata ??= {} as any) + if (node.message.metadata.citations?.length) { + prevMeta.citations = [ + ...(prevMeta.citations || []), + ...node.message.metadata.citations, + ] + } + if (node.message.metadata.content_references?.length) { + prevMeta.content_references = [ + ...(prevMeta.content_references || []), + ...node.message.metadata.content_references, + ] + } + } } else { result.push(node)