mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
bug(core): Prompt engineering for truncated read_file. (#5161)
This commit is contained in:
@@ -222,7 +222,7 @@ describe('ReadFileTool', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should pass offset and limit to read a slice of a text file', async () => {
|
||||
it('should return a structured message when a slice of a text file is read', async () => {
|
||||
const filePath = path.join(tempRootDir, 'paginated.txt');
|
||||
const fileContent = Array.from(
|
||||
{ length: 20 },
|
||||
@@ -240,15 +240,22 @@ describe('ReadFileTool', () => {
|
||||
ToolResult
|
||||
>;
|
||||
|
||||
expect(await invocation.execute(abortSignal)).toEqual({
|
||||
llmContent: [
|
||||
'[File content truncated: showing lines 6-8 of 20 total lines. Use offset/limit parameters to view more.]',
|
||||
'Line 6',
|
||||
'Line 7',
|
||||
'Line 8',
|
||||
].join('\n'),
|
||||
returnDisplay: 'Read lines 6-8 of 20 from paginated.txt',
|
||||
});
|
||||
const result = await invocation.execute(abortSignal);
|
||||
|
||||
const expectedLlmContent = `
|
||||
IMPORTANT: The file content has been truncated.
|
||||
Status: Showing lines 6-8 of 20 total lines.
|
||||
Action: To read more of the file, you can use the 'offset' and 'limit' parameters in a subsequent 'read_file' call. For example, to read the next section of the file, use offset: 8.
|
||||
|
||||
--- FILE CONTENT (truncated) ---
|
||||
Line 6
|
||||
Line 7
|
||||
Line 8`;
|
||||
|
||||
expect(result.llmContent).toEqual(expectedLlmContent);
|
||||
expect(result.returnDisplay).toBe(
|
||||
'Read lines 6-8 of 20 from paginated.txt',
|
||||
);
|
||||
});
|
||||
|
||||
describe('with .geminiignore', () => {
|
||||
|
||||
Reference in New Issue
Block a user