-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Issue Description:
Currently, the read_file tool relies on the LLM to be proactive about reading large files by specifying start_line and end_line. This is brittle because:
- The agent doesn't know a file's size until it tries to read it.
- If the agent reads a large file without specifying a range, it can flood its own context window, leading to poor performance, high token costs, and potential loss of important conversational history.
This issue proposes upgrading read_file to be "smarter" by default. It should automatically detect large files and, instead of returning the full content, return a more useful, context-rich partial view. This is inspired by the robust handling seen in mature coding agents.
Action Items:
-
When
read_fileis called withoutstart_lineorend_lineparameters:- The tool must first determine the total line count of the target file.
- If the line count is greater than a configurable threshold (
MAX_READ_LINES, e.g., 1000), automatic truncation and summarization logic is triggered. - If the line count is less than or equal to the threshold, the tool should function as it does now, returning the full file content.
-
When the truncation logic is triggered, the tool's JSON output must be enhanced to include:
content: The firstMAX_READ_LINESof the file.definitions: The output of calling thelist_code_definition_nameslogic for that same file.info: A new field containing a human-readable notice, e.g.,
"File truncated. Showing first 1000 of 5280 lines. Code definitions are provided for a high-level overview."
-
The
read_filetool must still respect the user-providedstart_lineandend_lineparameters, bypassing the large-file logic entirely if they are present.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request