Skip to content

Agent should request permission before reading or editing files #3205

Closed

Description

@rahulsan008

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.

Activity

  1. github-actions commented on Oct 16, 2025

    @github-actions
    Contributor

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

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

  2. rekram1-node commented on Oct 16, 2025

    @rekram1-node
    Contributor

    @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

  3. self-assigned this
    on Oct 16, 2025
  4. jamesforwardnwboxed commented on Oct 17, 2025

    @jamesforwardnwboxed

    @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...

  5. rekram1-node commented on Oct 17, 2025

    @rekram1-node
    Contributor

    @jamesforwardnwboxed here is a discussion about it: #2632 (comment)

    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?

  6. aaryan-rampal commented on Oct 27, 2025

    @aaryan-rampal

    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

  7. rekram1-node commented on Oct 27, 2025

    @rekram1-node
    Contributor

    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?

  8. aaryan-rampal commented on Oct 29, 2025

    @aaryan-rampal

    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?

  9. rekram1-node commented on Oct 29, 2025

    @rekram1-node
    Contributor

    @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/

  10. aaryan-rampal commented on Oct 29, 2025

    @aaryan-rampal

    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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions