Agent should request permission before reading or editing files #2122

Open
opened 2026-02-16 17:34:15 -05:00 by yindo · 9 comments
Owner

Originally created by @rahulsan008 on GitHub (Oct 16, 2025).

Originally assigned to: @rekram1-node on GitHub.

Currently, when using the OpenCode agent, it automatically reads or edits project files without explicitly asking for permission from the user.
For better transparency and safety — especially when working on unfamiliar or sensitive codebases — the agent should prompt the user for permission at least the first time it tries to:

  • Read files from the workspace
  • Modify or create new files

Expected Behavior

  • When the agent first attempts to read or edit files, it should show a confirmation prompt (e.g., “The agent wants to read files in /src — allow?”).
  • Optionally, provide a “remember this decision” checkbox or configuration setting.

Actual Behavior

  • The agent proceeds to read or modify files without any confirmation.
  • Sometimes it also edits unnecessary files without being explicitly instructed to do so.
Originally created by @rahulsan008 on GitHub (Oct 16, 2025). Originally assigned to: @rekram1-node on GitHub. Currently, when using the OpenCode agent, it automatically reads or edits project files without explicitly asking for permission from the user. For better transparency and safety — especially when working on unfamiliar or sensitive codebases — the agent should prompt the user for permission at least the first time it tries to: - Read files from the workspace - Modify or create new files Expected Behavior - When the agent first attempts to read or edit files, it should show a confirmation prompt (e.g., “The agent wants to read files in /src — allow?”). - Optionally, provide a “remember this decision” checkbox or configuration setting. Actual Behavior - The agent proceeds to read or modify files without any confirmation. - Sometimes it also edits unnecessary files without being explicitly instructed to do so.
Author
Owner

@github-actions[bot] commented on GitHub (Oct 16, 2025):

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

  • #2521: Feature Request: Add Prefix Requirements for Permission Prompts - discusses adding confirmation prompts for sensitive operations to prevent accidental approvals, similar to your request for permission prompts before file access
  • #1445: Allow for setting read-only files and directories - requests the ability to define specific files/directories as read-only to prevent unwanted modifications by the model

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

@github-actions[bot] commented on GitHub (Oct 16, 2025): This issue might be a duplicate of existing issues. Please check: - #2521: Feature Request: Add Prefix Requirements for Permission Prompts - discusses adding confirmation prompts for sensitive operations to prevent accidental approvals, similar to your request for permission prompts before file access - #1445: Allow for setting read-only files and directories - requests the ability to define specific files/directories as read-only to prevent unwanted modifications by the model Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Oct 16, 2025):

@rahulsan008 we have a permissions system, it is off by default intentionally.

Here are the docs: https://opencode.ai/docs/permissions/#_top

Sounds like you'd like the following:

{
  "$schema": "https://opencode.ai/config.json",
  "permission": {
    "edit": "ask",
    "bash": "ask",
  }
}

Read permissions, mcp permissions, and more are coming soon

@rekram1-node commented on GitHub (Oct 16, 2025): @rahulsan008 we have a permissions system, it is off by default intentionally. Here are the docs: https://opencode.ai/docs/permissions/#_top Sounds like you'd like the following: ``` { "$schema": "https://opencode.ai/config.json", "permission": { "edit": "ask", "bash": "ask", } } ``` Read permissions, mcp permissions, and more are coming soon
Author
Owner

@jamesforwardnwboxed commented on GitHub (Oct 17, 2025):

@rahulsan008 we have a permissions system, it is off by default intentionally.

Here are the docs: https://opencode.ai/docs/permissions/#_top

Sounds like you'd like the following:

{
  "$schema": "https://opencode.ai/config.json",
  "permission": {
    "edit": "ask",
    "bash": "ask",
  }
}

Read permissions, mcp permissions, and more are coming soon

Out of curiosity, why did you choose the unsafe option (off by default) over explicitly requesting permissions?
YOLO mode seems like something that really shouldn't be the default...

@jamesforwardnwboxed commented on GitHub (Oct 17, 2025): > [@rahulsan008](https://github.com/rahulsan008) we have a permissions system, it is off by default intentionally. > > Here are the docs: https://opencode.ai/docs/permissions/#_top > > Sounds like you'd like the following: > > ``` > { > "$schema": "https://opencode.ai/config.json", > "permission": { > "edit": "ask", > "bash": "ask", > } > } > ``` > > Read permissions, mcp permissions, and more are coming soon Out of curiosity, why did you choose the unsafe option (off by default) over explicitly requesting permissions? YOLO mode seems like something that really shouldn't be the default...
Author
Owner

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

@jamesforwardnwboxed here is a discussion about it: https://github.com/sst/opencode/issues/2632#issuecomment-3301703763

I wasn't a part of the decision making process it was prior to me joining the team, so I just wanna reference what Dax said directly.

That said, I do think there users who do not like this default and I was thinking we could solve it in one of the following ways:

  • make it easier to toggle permissions (similar to claude code how you can hit tab to switch between yolo and not << our keybind would be different but you get the idea)
  • possibly prompt user when they first run opencode, or maybe first time they run it in a new dir

I think I prefer option 1 ^ and then we could just save whatever mode you were last in so that you don't have to toggle all the time

What do u think?

@rekram1-node commented on GitHub (Oct 17, 2025): @jamesforwardnwboxed here is a discussion about it: https://github.com/sst/opencode/issues/2632#issuecomment-3301703763 I wasn't a part of the decision making process it was prior to me joining the team, so I just wanna reference what Dax said directly. That said, I do think there users who do not like this default and I was thinking we could solve it in one of the following ways: - make it easier to toggle permissions (similar to claude code how you can hit tab to switch between yolo and not << our keybind would be different but you get the idea) - possibly prompt user when they first run opencode, or maybe first time they run it in a new dir I think I prefer option 1 ^ and then we could just save whatever mode you were last in so that you don't have to toggle all the time What do u think?
Author
Owner

@aaryan-rampal commented on GitHub (Oct 27, 2025):

I think that would be super cool. Is any active work being done on this or is it open to pick up? I know you guys are redesigning the TUI completely, not sure if this was already considered

@aaryan-rampal commented on GitHub (Oct 27, 2025): I think that would be super cool. Is any active work being done on this or is it open to pick up? I know you guys are redesigning the TUI completely, not sure if this was already considered
Author
Owner

@rekram1-node commented on GitHub (Oct 27, 2025):

I think any work on it would be best done once the new rewrite at least launches in beta which should be super soon. But doesn't hurt to talk about it rn

And we would probably have some input on UX, do you have any ideas on how you think it should work?

@rekram1-node commented on GitHub (Oct 27, 2025): I think any work on it would be best done once the new rewrite at least launches in beta which should be super soon. But doesn't hurt to talk about it rn And we would probably have some input on UX, do you have any ideas on how you think it should work?
Author
Owner

@aaryan-rampal commented on GitHub (Oct 29, 2025):

Okay yeah sounds good. I guess since it's something that will only be used for build mode, maybe it's a toggle-able text field underneath build mode. Starts off with approve: auto and like shift-tab to turn it into approve: manual? One drawback I can see is that it might make that section of the UI more cluttered, but on the other hand you can look at one section and see exactly what mode (plan/build) and what mode (auto/manual) you're on.

Probably could also allow users to set up custom configs so like write allowed, bash not allowed, and it's just config files linked to the build option?

@aaryan-rampal commented on GitHub (Oct 29, 2025): Okay yeah sounds good. I guess since it's something that will only be used for build mode, maybe it's a toggle-able text field underneath build mode. Starts off with `approve: auto` and like shift-tab to turn it into `approve: manual`? One drawback I can see is that it might make that section of the UI more cluttered, but on the other hand you can look at one section and see exactly what mode (plan/build) and what mode (auto/manual) you're on. Probably could also allow users to set up custom configs so like `write allowed`, `bash not allowed`, and it's just config files linked to the build option?
Author
Owner

@rekram1-node commented on GitHub (Oct 29, 2025):

@aaryan-rampal

Probably could also allow users to set up custom configs so like write allowed, bash not allowed, and it's just config files linked to the build option?

This is already possible https://opencode.ai/docs/permissions/

@rekram1-node commented on GitHub (Oct 29, 2025): @aaryan-rampal > Probably could also allow users to set up custom configs so like write allowed, bash not allowed, and it's just config files linked to the build option? This is already possible https://opencode.ai/docs/permissions/
Author
Owner

@aaryan-rampal commented on GitHub (Oct 29, 2025):

Yes, but I am thinking they could maybe save these configs and cycle through them in any directory. So almost global configs which they can use anywhere

@aaryan-rampal commented on GitHub (Oct 29, 2025): Yes, but I am thinking they could maybe save these configs and cycle through them in *any* directory. So almost global configs which they can use anywhere
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2122