Replies: 3 comments
|
Thanks for raising this! This is the same underlying limitation tracked in #2142: when Eugene's stance on #2142 is that the "lines X–Y of Z, R remaining" notice is a good fix, but the team wants to benchmark the change before shipping it. No ETA yet, but #2142 is the issue to follow. Re: exposing Closing as a duplicate of #2142 — please subscribe there for updates. |
|
The from deepagents import skill
@skill()
async def read_file_full(path: str, offset: int = 0, limit: int = 200) -> str:
import pathlib
lines = pathlib.Path(path).read_text().splitlines()
chunk = lines[offset:offset + limit]
remaining = max(0, len(lines) - offset - limit)
result = "\n".join(chunk)
if remaining > 0:
result += f"\n\n[{remaining} more lines remain starting at line {offset + limit}]"
return resultInclude this skill alongside the built-in tools. The model will see the remaining line count in the output and know to call the tool again with the next offset. For the limit itself, a value of 500-800 lines works well for most code files without exceeding context. Larger limits increase token usage per call but reduce the number of reads needed for big files. |
|
The The practical workaround until this is configurable is to wrap from deepagents import skill
import pathlib
@skill()
async def read_file_paginated(path: str, offset: int = 0, limit: int = 200) -> str:
lines = pathlib.Path(path).read_text(errors="replace").splitlines()
total = len(lines)
chunk = lines[offset : offset + limit]
remaining = max(0, total - (offset + limit))
header = f"[Lines {offset+1}-{min(offset+limit, total)} of {total}. Remaining: {remaining}]\n"
return header + "\n".join(chunk)By returning A follow-up approach that avoids multi-turn reads entirely: for files under a size threshold, return the full content regardless of the limit; only paginate beyond that. Files up to ~10K tokens are almost always fine to read whole. |
Uh oh!
There was an error while loading. Please reload this page.
In the built-in tool
read_file, thelimitparameter is set by default to restrict the length of the file being read. When the file is too long, it is often read multiple times. However, this can sometimes lead to situations where the model thinks the reading is complete, but in fact, it hasn't finished reading. Could an interface for configuring thelimitparameter be made available increate_deep_agents? This would make it more flexible to use. Or are there any other solutions?All reactions