2025-06-16 08:27:29 -07:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2025-08-12 15:57:27 -07:00
|
|
|
import { describe, it, expect } from 'vitest';
|
2025-08-01 14:33:33 -07:00
|
|
|
import { TestRig, printDebugInfo, validateModelOutput } from './test-helper.js';
|
2025-06-16 08:27:29 -07:00
|
|
|
|
2025-08-12 15:57:27 -07:00
|
|
|
describe('read_many_files', () => {
|
2025-09-04 12:27:51 -07:00
|
|
|
it.skip('should be able to read multiple files', async () => {
|
2025-08-12 15:57:27 -07:00
|
|
|
const rig = new TestRig();
|
|
|
|
|
await rig.setup('should be able to read multiple files');
|
|
|
|
|
rig.createFile('file1.txt', 'file 1 content');
|
|
|
|
|
rig.createFile('file2.txt', 'file 2 content');
|
|
|
|
|
|
2025-09-03 13:40:19 -07:00
|
|
|
const prompt = `Use the read_many_files tool to read the contents of file1.txt and file2.txt and then print the contents of each file.`;
|
2025-08-12 15:57:27 -07:00
|
|
|
|
|
|
|
|
const result = await rig.run(prompt);
|
|
|
|
|
|
|
|
|
|
// Check for either read_many_files or multiple read_file calls
|
|
|
|
|
const allTools = rig.readToolLogs();
|
|
|
|
|
const readManyFilesCall = await rig.waitForToolCall('read_many_files');
|
|
|
|
|
const readFileCalls = allTools.filter(
|
|
|
|
|
(t) => t.toolRequest.name === 'read_file',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Accept either read_many_files OR at least 2 read_file calls
|
|
|
|
|
const foundValidPattern = readManyFilesCall || readFileCalls.length >= 2;
|
|
|
|
|
|
|
|
|
|
// Add debugging information
|
|
|
|
|
if (!foundValidPattern) {
|
|
|
|
|
printDebugInfo(rig, result, {
|
|
|
|
|
'read_many_files called': readManyFilesCall,
|
|
|
|
|
'read_file calls': readFileCalls.length,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
expect(
|
|
|
|
|
foundValidPattern,
|
|
|
|
|
'Expected to find either read_many_files or multiple read_file tool calls',
|
|
|
|
|
).toBeTruthy();
|
|
|
|
|
|
2025-09-03 13:40:19 -07:00
|
|
|
// Validate model output - will throw if no output
|
|
|
|
|
validateModelOutput(result, null, 'Read many files test');
|
2025-08-12 15:57:27 -07:00
|
|
|
});
|
2025-06-16 08:27:29 -07:00
|
|
|
});
|