fix(citations): use all sub-question sources for citation lookup

LLMs may cite chunks from one sub-question's context inside another sub-question's answer section. Previously, processCitationsForSubq only looked up the current sub-question's sources, leaving cross-referenced citations unlinked. Now SubQuestionSection passes all sub-question sources and uses processCitations with a combined flat lookup.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
Woody 2026-04-28 17:10:02 +08:00
parent 48e15f8232
commit 4058c7dffe
1 changed files with 7 additions and 1 deletions

View File

@ -70,13 +70,18 @@ function SubQuestionSection({
index,
subQuestion,
answerSection,
allSubQuestionSources,
}: {
index: number
subQuestion: SubQuestionSources
answerSection: string
allSubQuestionSources: SubQuestionSources[]
}) {
const [expanded, setExpanded] = useState(false)
const processedAnswer = processCitationsForSubq(answerSection, [subQuestion], 0)
// Look up citations across ALL sub-questions' sources because the LLM
// may cite chunks from other sub-questions' contexts.
const allSources = allSubQuestionSources.flatMap(sq => sq.sources)
const processedAnswer = processCitations(answerSection, allSources)
return (
<div
@ -211,6 +216,7 @@ function SubQuestionSections({
index={index}
subQuestion={subQuestion}
answerSection={sections[index] ?? ''}
allSubQuestionSources={subQuestionSources}
/>
))}
</div>