Skip to content

Commit 5518a13

Browse files
committed
limit maximum size of supplementalContext being sent
1 parent 42f49a8 commit 5518a13

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

packages/core/src/codewhisperer/models/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,7 @@ export const crossFileContextConfig = {
712712
numberOfChunkToFetch: 60,
713713
topK: 3,
714714
numberOfLinesEachChunk: 50,
715+
maximumTotalLength: 10240,
715716
}
716717

717718
export const utgConfig = {

packages/core/src/codewhisperer/util/supplementalContext/crossFileContextUtil.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,20 @@ export async function fetchSupplementalContextForSrcV1(
132132

133133
// Step 4: Transform best chunks to supplemental contexts
134134
const supplementalContexts: CodeWhispererSupplementalContextItem[] = []
135+
let totalLength = 0
135136
for (const chunk of bestChunks) {
136137
throwIfCancelled(cancellationToken)
137138

139+
if (totalLength > crossFileContextConfig.maximumTotalLength) {
140+
break
141+
}
142+
138143
supplementalContexts.push({
139144
filePath: chunk.fileName,
140145
content: chunk.nextContent,
141146
score: chunk.score,
142147
})
148+
totalLength += chunk.nextContent.length
143149
}
144150

145151
// DO NOT send code chunk with empty content

0 commit comments

Comments
 (0)