File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
server/aws-lsp-codewhisperer/src/language-server/agenticChat/context/memorybank Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -433,18 +433,26 @@ export class MemoryBankController {
433433 throw new Error ( 'No source files found in workspace' )
434434 }
435435
436+ // Filter out very large files to prevent conversation overflow
437+ const MAX_FILE_SIZE_FOR_MEMORY_BANK = 20000 // 20KB limit
438+ const reasonableSizedFiles = discoveredFiles . filter ( file => file . size <= MAX_FILE_SIZE_FOR_MEMORY_BANK )
439+
440+ this . features . logging . debug (
441+ `Memory Bank analysis: filtered ${ discoveredFiles . length - reasonableSizedFiles . length } files over ${ MAX_FILE_SIZE_FOR_MEMORY_BANK } characters`
442+ )
443+
436444 // Limit files to prevent memory exhaustion on large projects
437445 const MAX_FILES_FOR_ANALYSIS = 200
438446 let filesToAnalyze : Array < { path : string ; size : number } >
439447
440- if ( discoveredFiles . length > MAX_FILES_FOR_ANALYSIS ) {
441- const shuffled = [ ...discoveredFiles ] . sort ( ( ) => Math . random ( ) - 0.5 )
448+ if ( reasonableSizedFiles . length > MAX_FILES_FOR_ANALYSIS ) {
449+ const shuffled = [ ...reasonableSizedFiles ] . sort ( ( ) => Math . random ( ) - 0.5 )
442450 filesToAnalyze = shuffled . slice ( 0 , MAX_FILES_FOR_ANALYSIS )
443451 this . features . logging . info (
444- `Memory Bank analysis: randomly selected ${ filesToAnalyze . length } files (from ${ discoveredFiles . length } discovered) `
452+ `Memory Bank analysis: randomly selected ${ filesToAnalyze . length } files (from ${ reasonableSizedFiles . length } reasonable-sized files) to prevent memory issues `
445453 )
446454 } else {
447- filesToAnalyze = discoveredFiles
455+ filesToAnalyze = reasonableSizedFiles
448456 }
449457
450458 // Step 2: Calculate lexical dissimilarity using TF-IDF
You can’t perform that action at this time.
0 commit comments