feat(core): centralize read_file limits and update gemini-3 description (#20619)

This commit is contained in:
Aishanee Shah
2026-03-02 15:11:58 -05:00
committed by GitHub
parent 446a4316c4
commit 659301ff83
6 changed files with 30 additions and 10 deletions

View File

@@ -6,3 +6,7 @@
export const REFERENCE_CONTENT_START = '--- Content from referenced files ---';
export const REFERENCE_CONTENT_END = '--- End of content ---';
export const DEFAULT_MAX_LINES_TEXT_FILE = 2000;
export const MAX_LINE_LENGTH_TEXT_FILE = 2000;
export const MAX_FILE_SIZE_MB = 20;

View File

@@ -15,6 +15,11 @@ import { ToolErrorType } from '../tools/tool-error.js';
import { BINARY_EXTENSIONS } from './ignorePatterns.js';
import { createRequire as createModuleRequire } from 'node:module';
import { debugLogger } from './debugLogger.js';
import {
DEFAULT_MAX_LINES_TEXT_FILE,
MAX_LINE_LENGTH_TEXT_FILE,
MAX_FILE_SIZE_MB,
} from './constants.js';
const requireModule = createModuleRequire(import.meta.url);
@@ -52,10 +57,6 @@ export async function loadWasmBinary(
}
}
// Constants for text file processing
export const DEFAULT_MAX_LINES_TEXT_FILE = 2000;
const MAX_LINE_LENGTH_TEXT_FILE = 2000;
// Default values for encoding and separator format
export const DEFAULT_ENCODING: BufferEncoding = 'utf-8';
@@ -434,11 +435,11 @@ export async function processSingleFileContent(
}
const fileSizeInMB = stats.size / (1024 * 1024);
if (fileSizeInMB > 20) {
if (fileSizeInMB > MAX_FILE_SIZE_MB) {
return {
llmContent: 'File size exceeds the 20MB limit.',
returnDisplay: 'File size exceeds the 20MB limit.',
error: `File size exceeds the 20MB limit: ${filePath} (${fileSizeInMB.toFixed(2)}MB)`,
llmContent: `File size exceeds the ${MAX_FILE_SIZE_MB}MB limit.`,
returnDisplay: `File size exceeds the ${MAX_FILE_SIZE_MB}MB limit.`,
error: `File size exceeds the ${MAX_FILE_SIZE_MB}MB limit: ${filePath} (${fileSizeInMB.toFixed(2)}MB)`,
errorType: ToolErrorType.FILE_TOO_LARGE,
};
}