Tool incorrectly attempts to read .env files and gets blocked repeatedly #3835

Closed
opened 2026-02-16 17:41:38 -05:00 by yindo · 4 comments
Owner

Originally created by @jcbbge on GitHub (Dec 24, 2025).

Originally assigned to: @thdxr on GitHub.

Description
The Read tool attempts to read .env files, gets blocked by security restrictions, and then continues with tasks as if nothing happened. This creates a frustrating user experience where the assistant repeatedly tries to access blocked files instead of asking the user to provide the needed information.

Expected Behavior
Either:

  1. Don't attempt to read .env files at all and ask users for needed contents, OR
  2. If blocked once, remember the block and ask instead of retrying

Current Behavior

  • Assistant tries to read .env file
  • Gets blocked with message: "The user has blocked you from reading [path], DO NOT make further attempts to read it"
  • Assistant continues with tasks, potentially retrying the same read in future

Impact

  • Frustrating user experience
  • Wasted tool calls
  • Breaks conversational flow
  • Happens repeatedly across sessions

Suggested Fix
Add logic to detect .env file patterns (.env, .env.*, etc.) and either:

  1. Automatically ask users to share contents instead of attempting to read
  2. Cache the block state and automatically ask instead of retrying
    This is a fundamental UX issue that needs to be addressed at the tool/system level
Originally created by @jcbbge on GitHub (Dec 24, 2025). Originally assigned to: @thdxr on GitHub. Description The Read tool attempts to read .env files, gets blocked by security restrictions, and then continues with tasks as if nothing happened. This creates a frustrating user experience where the assistant repeatedly tries to access blocked files instead of asking the user to provide the needed information. Expected Behavior Either: 1. Don't attempt to read .env files at all and ask users for needed contents, OR 2. If blocked once, remember the block and ask instead of retrying Current Behavior - Assistant tries to read .env file - Gets blocked with message: "The user has blocked you from reading [path], DO NOT make further attempts to read it" - Assistant continues with tasks, potentially retrying the same read in future Impact - Frustrating user experience - Wasted tool calls - Breaks conversational flow - Happens repeatedly across sessions Suggested Fix Add logic to detect .env file patterns (.env, .env.*, etc.) and either: 1. Automatically ask users to share contents instead of attempting to read 2. Cache the block state and automatically ask instead of retrying This is a fundamental UX issue that needs to be addressed at the tool/system level
yindo closed this issue 2026-02-16 17:41:38 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 24, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #4969: Overly restrictive .env file blocking prevents reading legitimate files
  • #5484: Will not read env even with config set
  • #4739: Unignoring the .gitignore with .ignore should allow reading the file

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Dec 24, 2025): This issue might be a duplicate of existing issues. Please check: - #4969: Overly restrictive .env file blocking prevents reading legitimate files - #5484: Will not read env even with config set - #4739: Unignoring the .gitignore with .ignore should allow reading the file Feel free to ignore if none of these address your specific case.
Author
Owner

@dhruvkej9 commented on GitHub (Dec 24, 2025):

opencode today read my .env using "cat .env"

It was not blocked also

@dhruvkej9 commented on GitHub (Dec 24, 2025): opencode today read my .env using "cat .env" It was not blocked also
Author
Owner

@boxpositron commented on GitHub (Jan 12, 2026):

I had a similar problem. I created an OpenCode plugin https://github.com/boxpositron/envsitter-guard that solves this exact problem.

@boxpositron commented on GitHub (Jan 12, 2026): I had a similar problem. I created an OpenCode plugin https://github.com/boxpositron/envsitter-guard that solves this exact problem.
Author
Owner

@rekram1-node commented on GitHub (Jan 13, 2026):

switched from deny to ask to prevent this

@rekram1-node commented on GitHub (Jan 13, 2026): switched from deny to ask to prevent this
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3835