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) <noreply@anthropic.com>
This commit is contained in:
pionxzh
2026-05-10 05:04:22 +08:00
parent 4df6676826
commit 5cd8986e42

View File

@@ -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)