[PR #2161] Refuse to read a large file #10215

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

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

State: closed
Merged: No


• New file added: packages/opencode/src/file/context.ts - Implements file context tracking for sessions
• Modified: packages/opencode/src/tool/grep.ts - Added file context recording for grep operations
• Modified: packages/opencode/src/tool/read.ts - Added file size checking with context-aware logic and recording reads

These changes implement a file context tracking system that:

  1. Tracks which files have been read/grepped in each session
  2. Prevents direct reading of large files (>200KB) unless they've been previously searched
  3. Records file operations in session context

This is a feature enhancement that adds smarter file handling with size limitations based on context.

This small change can significantly improve the performance of opencode in large files (large projects), and will force opencode to use the grep tool instead of reading files mindlessly.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/2161 **State:** closed **Merged:** No --- • New file added: packages/opencode/src/file/context.ts - Implements file context tracking for sessions • Modified: packages/opencode/src/tool/grep.ts - Added file context recording for grep operations • Modified: packages/opencode/src/tool/read.ts - Added file size checking with context-aware logic and recording reads These changes implement a file context tracking system that: 1. Tracks which files have been read/grepped in each session 2. Prevents direct reading of large files (>200KB) unless they've been previously searched 3. Records file operations in session context This is a feature enhancement that adds smarter file handling with size limitations based on context. This small change can significantly improve the performance of opencode in large files (large projects), and will force opencode to use the grep tool instead of reading files mindlessly.
yindo added the pull-request label 2026-02-16 18:14:50 -05:00
yindo closed this issue 2026-02-16 18:14:50 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10215