summaryrefslogtreecommitdiff
path: root/packages/core/src/tools/read-many-files.test.ts
diff options
context:
space:
mode:
authorjoshualitt <[email protected]>2025-08-06 13:52:04 -0700
committerGitHub <[email protected]>2025-08-06 20:52:04 +0000
commit43510ed212ea29b7bd752277de525f7821551b22 (patch)
treeb49f31ec75804e2b742b2651714066211421c3ab /packages/core/src/tools/read-many-files.test.ts
parentad5d2af4e34fd23391bb6a0270cc320a0e56ba88 (diff)
bug(core): Prompt engineering for truncated read_file. (#5161)
Diffstat (limited to 'packages/core/src/tools/read-many-files.test.ts')
-rw-r--r--packages/core/src/tools/read-many-files.test.ts28
1 files changed, 28 insertions, 0 deletions
diff --git a/packages/core/src/tools/read-many-files.test.ts b/packages/core/src/tools/read-many-files.test.ts
index 6ddd2a08..4035a6b7 100644
--- a/packages/core/src/tools/read-many-files.test.ts
+++ b/packages/core/src/tools/read-many-files.test.ts
@@ -476,6 +476,34 @@ describe('ReadManyFilesTool', () => {
fs.rmSync(tempDir1, { recursive: true, force: true });
fs.rmSync(tempDir2, { recursive: true, force: true });
});
+
+ it('should add a warning for truncated files', async () => {
+ createFile('file1.txt', 'Content1');
+ // Create a file that will be "truncated" by making it long
+ const longContent = Array.from({ length: 2500 }, (_, i) => `L${i}`).join(
+ '\n',
+ );
+ createFile('large-file.txt', longContent);
+
+ const params = { paths: ['*.txt'] };
+ const result = await tool.execute(params, new AbortController().signal);
+ const content = result.llmContent as string[];
+
+ const normalFileContent = content.find((c) => c.includes('file1.txt'));
+ const truncatedFileContent = content.find((c) =>
+ c.includes('large-file.txt'),
+ );
+
+ expect(normalFileContent).not.toContain(
+ '[WARNING: This file was truncated.',
+ );
+ expect(truncatedFileContent).toContain(
+ "[WARNING: This file was truncated. To view the full content, use the 'read_file' tool on this specific file.]",
+ );
+ // Check that the actual content is still there but truncated
+ expect(truncatedFileContent).toContain('L200');
+ expect(truncatedFileContent).not.toContain('L2400');
+ });
});
describe('Batch Processing', () => {