You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Read tool accepts offset <= 0, negative-slicing the file and returning its tail labeled with line numbers 0 or negative #3291
I have searched the existing issues and discussions, and this is not a duplicate.
This is a bug, not a usage question. (For questions, please use Discussions instead.)
Background / Description
The Read tool's parameter schema declares offset as a 1-based line number with ge=1, and limit with ge=1, le=2000 (src/agentscope/tool/_builtin/_read.py), but nothing enforces them at runtime. When a caller passes offset=0 (an easy 0-based off-by-one mistake for an LLM) or a negative offset, the slice lines[start_idx:end_idx] with a negative start_idx walks backwards from the end of the file, so the tool silently returns the tail of the file labeled with line numbers 0 or negative — with a success state. limit=0 likewise returns empty text with a success state.
Since the tool reports success, the model has no signal to self-correct; it receives content from the wrong part of the file labeled with impossible line numbers.
The sibling tools already reject this class of input at runtime: Grep returns Error: offset must be non-negative. / Error: head_limit must be non-negative. and Glob does the same for its pagination arguments.
Error Messages
No error is produced — that is the bug. On main (2.0.10dev), reading a 10-line file with offset=0 succeeds and returns:
--- offset=0, state=running ---
0 line 10
--- offset=-3, state=running ---
-3 line 7
-2 line 8
-1 line 9
0 line 10
--- limit=0, state=running ---
''
It's yours, @SSK988I. If there is no pull request and no word from you by 2026-10-27 the claim is released so nobody is blocked — a comment here renews it.
Activity
SSK988I commentedon Oct 13, 2026
/assign
github-actions commentedon Oct 13, 2026
It's yours, @SSK988I. If there is no pull request and no word from you by 2026-10-27 the claim is released so nobody is blocked — a comment here renews it.