fix(tools): keep read_file progressing when a single line exceeds the output budget
ReadFileTool stops at the first numbered line that does not fit the 128 KiB budget. When that line is the first one, no line is appended and the tool returns an empty page that reports lines 2-1 and repeats the same offset, so the caller can never reach the rest of the file. A long line further down has the same effect for everything after it. Emit a bounded prefix of that line and advance the continuation offset past it, so every read returns content and makes progress.
This commit is contained in:
1 parent
a724ad4fcd
commit
f57eba2b07
2 files changed
+37
No files matched your search
@@ -403,6 +403,11 @@ class ReadFileTool(_FsTool):
|
||||
for line in numbered:
|
||||
chars += len(line) + 1
|
||||
if chars > self._MAX_CHARS:
|
||||
if not trimmed:
|
||||
# Do not leave the reader at the same offset when a
|
||||
# single numbered line exceeds the entire budget.
|
||||
# Return a bounded prefix and advance past the line.
|
||||
trimmed.append(line[: self._MAX_CHARS])
|
||||
break
|
||||
trimmed.append(line)
|
||||
end = start + len(trimmed)
|
||||
|
||||
Reference in new issue
Block a user