[PR #5045] feat: writing filetime reads to disk to persist across process being killed #11223

Closed
opened 2026-02-16 18:16:01 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/5045

State: closed
Merged: No


Addressing Issue https://github.com/sst/opencode/issues/4406

File read content saved to disk associated timestamp existed beyond solely in memory.

It would lead to double reads when you read a chat in a session -> kill it -> revisit the session and try to invoke write tool call

Steps to reproduce bug:
Read a file read index.ts
Exit via ctrl + c
Reinit your local -> bun dev
Go back to the session -> bun dev + /session (find session you just read index.ts in )

Ask it to write a comment on top of index.ts -> throws an error saying you didn't read it -> re-reads wastes tokens

Example:
Screenshot 2025-12-03 at 11 29 02 PM

Solution:

We are already persisting the read tool call output. However, we didn't have a way to know how when it happened. So, we write to disk when the read time was. We were already doing the in memory check but added backup to persist across releases.

Screenshot 2025-12-04 at 12 10 52 AM

Other Conditions I considered:

Changing a file between a save that you want to edit will STILL force a re-read (intended behaviour):
Screenshot 2025-12-04 at 12 01 55 AM

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/5045 **State:** closed **Merged:** No --- #### Addressing Issue https://github.com/sst/opencode/issues/4406 File read content saved to disk associated timestamp existed beyond solely in memory. It would lead to double reads when you read a chat in a session -> kill it -> revisit the session and try to invoke write tool call Steps to reproduce bug: Read a file `read index.ts` Exit via `ctrl + c` Reinit your local -> bun dev Go back to the session -> `bun dev` + `/session` (find session you just read `index.ts` in ) Ask it to `write a comment on top of index.ts` -> throws an error saying you didn't read it -> re-reads wastes tokens Example: <img width="1728" height="1022" alt="Screenshot 2025-12-03 at 11 29 02 PM" src="https://github.com/user-attachments/assets/c56c895b-182b-484e-936a-5a98d258cd33" /> #### Solution: We are already persisting the read tool call output. However, we didn't have a way to know how when it happened. So, we write to disk when the read time was. We were already doing the in memory check but added backup to persist across releases. <img width="1359" height="869" alt="Screenshot 2025-12-04 at 12 10 52 AM" src="https://github.com/user-attachments/assets/9b100d61-5151-43a3-abf8-a32ab863375a" /> #### Other Conditions I considered: Changing a file between a save that you want to edit will STILL force a re-read (intended behaviour): <img width="1358" height="816" alt="Screenshot 2025-12-04 at 12 01 55 AM" src="https://github.com/user-attachments/assets/4e81a830-36a6-4546-a612-0385f79db9d0" />
yindo added the pull-request label 2026-02-16 18:16:01 -05:00
yindo closed this issue 2026-02-16 18:16:01 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11223