fix(tools): Add an end of file list marker to ReadManyFilesTool (#5967)

Co-authored-by: Gal Zahavi <38544478+galz10@users.noreply.github.com>
Co-authored-by: Allen Hutchison <adh@google.com>
This commit is contained in:
Victor Miura
2025-08-22 08:10:14 -07:00
committed by GitHub
parent 528227a0f8
commit 31cd35b8c4
5 changed files with 24 additions and 8 deletions

View File

@@ -221,6 +221,7 @@ describe('ReadManyFilesTool', () => {
const expectedPath = path.join(tempRootDir, 'file1.txt');
expect(result.llmContent).toEqual([
`--- ${expectedPath} ---\n\nContent of file1\n\n`,
`\n--- End of content ---`,
]);
expect(result.returnDisplay).toContain(
'Successfully read and concatenated content from **1 file(s)**',
@@ -285,7 +286,10 @@ describe('ReadManyFilesTool', () => {
const result = await invocation.execute(new AbortController().signal);
const content = result.llmContent as string[];
const expectedPath = path.join(tempRootDir, 'src/main.ts');
expect(content).toEqual([`--- ${expectedPath} ---\n\nMain content\n\n`]);
expect(content).toEqual([
`--- ${expectedPath} ---\n\nMain content\n\n`,
`\n--- End of content ---`,
]);
expect(
content.find((c) => c.includes('src/main.test.ts')),
).toBeUndefined();
@@ -314,7 +318,10 @@ describe('ReadManyFilesTool', () => {
const result = await invocation.execute(new AbortController().signal);
const content = result.llmContent as string[];
const expectedPath = path.join(tempRootDir, 'src/app.js');
expect(content).toEqual([`--- ${expectedPath} ---\n\napp code\n\n`]);
expect(content).toEqual([
`--- ${expectedPath} ---\n\napp code\n\n`,
`\n--- End of content ---`,
]);
expect(
content.find((c) => c.includes('node_modules/some-lib/index.js')),
).toBeUndefined();
@@ -367,6 +374,7 @@ describe('ReadManyFilesTool', () => {
mimeType: 'image/png',
},
},
'\n--- End of content ---',
]);
expect(result.returnDisplay).toContain(
'Successfully read and concatenated content from **1 file(s)**',
@@ -390,6 +398,7 @@ describe('ReadManyFilesTool', () => {
mimeType: 'image/png',
},
},
'\n--- End of content ---',
]);
});
@@ -426,6 +435,7 @@ describe('ReadManyFilesTool', () => {
mimeType: 'application/pdf',
},
},
'\n--- End of content ---',
]);
});
@@ -441,6 +451,7 @@ describe('ReadManyFilesTool', () => {
mimeType: 'application/pdf',
},
},
'\n--- End of content ---',
]);
});
@@ -549,6 +560,7 @@ describe('ReadManyFilesTool', () => {
Content of receive-detail
`,
`\n--- End of content ---`,
]);
expect(result.returnDisplay).toContain(
'Successfully read and concatenated content from **1 file(s)**',
@@ -567,6 +579,7 @@ Content of receive-detail
Content of file[1]
`,
`\n--- End of content ---`,
]);
expect(result.returnDisplay).toContain(
'Successfully read and concatenated content from **1 file(s)**',
@@ -634,9 +647,10 @@ Content of file[1]
const invocation = tool.build(params);
const result = await invocation.execute(new AbortController().signal);
// Verify all files were processed
// Verify all files were processed. The content should have fileCount
// entries + 1 for the output terminator.
const content = result.llmContent as string[];
expect(content).toHaveLength(fileCount);
expect(content).toHaveLength(fileCount + 1);
for (let i = 0; i < fileCount; i++) {
expect(content.join('')).toContain(`Batch test ${i}`);
}