Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions packages/types/src/file-limits.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* File size and limit constants used across the application
*/

/**
* Files larger than this threshold will be checked for token count
* to prevent consuming too much of the context window
*/
export const LARGE_FILE_SIZE_THRESHOLD = 100 * 1024 // 100KB

/**
* Files larger than this size will have the safeguard applied automatically
* without token counting
*/
export const VERY_LARGE_FILE_SIZE = 1024 * 1024 // 1MB

/**
* Default number of lines to read when applying the large file safeguard
*/
export const FALLBACK_MAX_LINES = 2000

/**
* Maximum character count for file reading when safeguard is applied.
* Based on typical token-to-character ratio (1 token ≈ 4 characters),
* this ensures we don't consume too much of the context window.
* For a 100k token context window at 50%, this would be ~200k characters.
*/
export const MAX_CHAR_LIMIT = 200_000 // 200k characters

/**
* Percentage of the context window to use as the maximum token threshold
* for file reading operations
*/
export const CONTEXT_WINDOW_PERCENTAGE = 0.5 // 50%

/**
* Average characters per token ratio used for estimation
*/
export const CHARS_PER_TOKEN_RATIO = 4
1 change: 1 addition & 0 deletions packages/types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from "./api.js"
export * from "./codebase-index.js"
export * from "./cloud.js"
export * from "./experiment.js"
export * from "./file-limits.js"
export * from "./followup.js"
export * from "./global-settings.js"
export * from "./history.js"
Expand Down
Loading