Skip to content

Commit da91aa2

Browse files
committed
Don't include knowledge files again when reading files for the first time
1 parent 5b7c777 commit da91aa2

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

backend/src/get-file-reading-updates.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,7 @@ export async function getFileReadingUpdates(
6767
const requestedFiles = options.requestedFiles ?? []
6868

6969
const isFirstRead = previousFileList.length === 0
70-
const initialFiles = getInitialFiles(fileContext)
71-
const includedInitialFiles = isFirstRead
72-
? initialFiles.map(({ path }) => path)
73-
: []
74-
7570
const allFilePaths = uniq([
76-
...includedInitialFiles,
7771
...requestedFiles,
7872
...editedFilePaths,
7973
...previousFilePaths,
@@ -89,10 +83,7 @@ export async function getFileReadingUpdates(
8983
}
9084
return tokenCount < 10_000
9185
})
92-
const newFiles = difference(
93-
[...filteredRequestedFiles, ...includedInitialFiles],
94-
previousFilePaths,
95-
)
86+
const newFiles = difference(filteredRequestedFiles, previousFilePaths)
9687
const newFilesToRead = uniq([
9788
// NOTE: When the assistant specifically asks for a file, we force it to be shown even if it's not new or changed.
9889
...(options.requestedFiles ?? []),
@@ -106,11 +97,7 @@ export async function getFileReadingUpdates(
10697
},
10798
)
10899

109-
const addedFiles = uniq([
110-
...includedInitialFiles,
111-
...updatedFilePaths,
112-
...newFilesToRead,
113-
])
100+
const addedFiles = uniq([...updatedFilePaths, ...newFilesToRead])
114101
.map((path) => {
115102
return {
116103
path,
@@ -127,7 +114,7 @@ export async function getFileReadingUpdates(
127114
path,
128115
content: loadedFiles[path]!,
129116
}))
130-
const newFiles = uniq([...initialFiles, ...requestedLoadedFiles])
117+
const newFiles = uniq(requestedLoadedFiles)
131118
while (countTokensJson(newFiles) > FILE_TOKEN_BUDGET) {
132119
newFiles.pop()
133120
}

0 commit comments

Comments
 (0)