Should the read tool throw an error when the offset is negative? #2908

Open
opened 2026-02-16 17:37:45 -05:00 by yindo · 3 comments
Owner

Originally created by @Mattwmaster58 on GitHub (Nov 16, 2025).

Description

Lots of negative offsets trying to read the file with GPT-4.1 via Copilot, this is when it's context window is close. I figure it wouldn't hurt to throw an error for negative file offsets? Eventually, it tried read negative 2000 lines and got out of the loop. I doubt this behavior is useful even if negative slices does work in TS.

→ Read tests/test_order_book_collection.py [limit=40, offset=-1780]
→ Read tests/test_order_book_collection.py [limit=40, offset=-1800]
→ Read tests/test_order_book_collection.py [limit=40, offset=-1820]
→ Read tests/test_order_book_collection.py [limit=40, offset=-1840]
→ Read tests/test_order_book_collection.py [limit=40, offset=-1860]
→ Read tests/test_order_book_collection.py [limit=40, offset=-1880]

OpenCode version

1.0.44

Steps to reproduce

Use GPT-4.1, get close to filling context window up, observe erratic behavior.

Screenshot and/or share link

Can DM share link, would rather not have it posted on the open internet.

Image

Operating System

linux

Terminal

ghostty

Originally created by @Mattwmaster58 on GitHub (Nov 16, 2025). ### Description Lots of negative offsets trying to read the file with GPT-4.1 via Copilot, this is when it's context window is close. I figure it wouldn't hurt to throw an error for negative file offsets? Eventually, it tried read negative 2000 lines and got out of the loop. I doubt this behavior is useful even if negative slices does work in TS. → Read tests/test_order_book_collection.py [limit=40, offset=-1780] → Read tests/test_order_book_collection.py [limit=40, offset=-1800] → Read tests/test_order_book_collection.py [limit=40, offset=-1820] → Read tests/test_order_book_collection.py [limit=40, offset=-1840] → Read tests/test_order_book_collection.py [limit=40, offset=-1860] → Read tests/test_order_book_collection.py [limit=40, offset=-1880] ### OpenCode version 1.0.44 ### Steps to reproduce Use GPT-4.1, get close to filling context window up, observe erratic behavior. ### Screenshot and/or share link Can DM share link, would rather not have it posted on the open internet. <img width="1181" height="867" alt="Image" src="https://github.com/user-attachments/assets/fdbcd82d-9888-4f08-9b55-4acb29bba083" /> ### Operating System linux ### Terminal ghostty
yindo added the bug label 2026-02-16 17:37:45 -05:00
Author
Owner

@rekram1-node commented on GitHub (Nov 17, 2025):

how often have u seen this looping issue?

@rekram1-node commented on GitHub (Nov 17, 2025): how often have u seen this looping issue?
Author
Owner

@Mattwmaster58 commented on GitHub (Nov 17, 2025):

First time seeing the issue, I was trying to get opencode to read a 200k token line. I kept trying to get it to be smart and read part of the json object so it wouldn't murder its own context window, so I tried this a few times. Every time is failed because it filled its own context window, but only once did it start going crazy with negative line offsets.

@Mattwmaster58 commented on GitHub (Nov 17, 2025): First time seeing the issue, I was trying to get opencode to read a 200k token line. I kept trying to get it to be smart and read part of the json object so it wouldn't murder its own context window, so I tried this a few times. Every time is failed because it filled its own context window, but only once did it start going crazy with negative line offsets.
Author
Owner

@rekram1-node commented on GitHub (Nov 17, 2025):

Hmm interesting

@rekram1-node commented on GitHub (Nov 17, 2025): Hmm interesting
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2908