Skip to content

Commit 37b71eb

Browse files
committed
fix: dedup references by URL in agent
1 parent 1d531ce commit 37b71eb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/agent.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,9 @@ But then you realized you have asked them before. You decided to to think out of
823823
isAggregated: true
824824
} as AnswerAction;
825825
candidateAnswers = subproblemResponses.map(r => (r.result as AnswerAction).mdAnswer).filter(a => a) as string[];
826+
// dedup references by their urls
827+
const uniqueURLs = new Set(thisStep.references.map(r => r.url));
828+
thisStep.references = Array.from(uniqueURLs).map(url => (thisStep as AnswerAction).references.find(r => r?.url === url)) as Reference[];
826829

827830
// aggregate urls
828831
visitedURLs.push(...subproblemResponses.map(r => r.readURLs).flat());

0 commit comments

Comments
 (0)