Elffuss BraidHub

kikocis/continue public

fix: truncate Read tool output to avoid context overflow
Changesetf2228a904ad3941f84afbfbbf1bc5194034778f6f197832d40fadc0304d0158f
AuthorNate <sestinj@gmail.com> · 2025-08-22 19:01 -07:00
CommitterNate <sestinj@gmail.com> · 2025-08-22 19:01 -07:00
Parents8d79223bfeb8

Browse the files at this changeset

1 file changed

modified extensions/cli/src/tools/readFile.ts +7 −0
@@ -39,6 +39,13 @@
3939 const content = fs.readFileSync(args.filepath, "utf-8");
4040 // Mark this file as read for the edit tool
4141 markFileAsRead(args.filepath);
42+
43+ const lines = content.split('\n');
44+ if (lines.length > 5000) {
45+ const truncatedContent = lines.slice(0, 5000).join('\n');
46+ return `Content of ${args.filepath} (truncated to first 5000 lines of ${lines.length} total):\n${truncatedContent}`;
47+ }
48+
4249 return `Content of ${args.filepath}:\n${content}`;
4350 } catch (error) {
4451 return `Error reading file: ${