Skip to content

Check what an agent may change before you let it

Draft: not yet validated

The AI assistant that drafted this tutorial ran every command on this page in MESA JupyterLab on 2026-11-20 (OpenCode 1.19.4) and saw the results shown. It did not test what a shell command run by the agent may reach, or the question the OpenCode screen asks. Nobody has yet followed the page as a reader would. Tell us what you find.

You may expect an agent to ask before it changes a file. In a MESA app, OpenCode's default agent does not: inside the folder where you start it, it writes at once. Find out where its limits are in a folder that holds nothing you care about.

You will: know what your agent changes without asking, what stops it, and how to run it so that it changes nothing.

Time: 10 minutes. You need: to have finished Sign in and start an AI agent in a MESA app in this app session. If the agent is open, type /exit first.

Steps

  1. In the terminal, make a scratch folder and move into it:

    mkdir -p ~/work/agent-test && cd ~/work/agent-test
    

    You should see: the prompt, now ending agent-test.

  2. Read the first rule of the default agent, build:

    opencode agent list | head -7
    

    You should see: permission * with action allow. Everything is allowed unless a later rule says otherwise. The full list is long; the later rules for build ask only for paths outside the starting folder and for files ending .env.

    build (primary)
      [
      {
        "permission": "*",
        "action": "allow",
        "pattern": "*"
      },
    
  3. Test it. Ask for a file in this folder:

    opencode run "Create a file named agent-note.txt in the current folder containing the single line: written by the agent. Then stop."
    

    You should see: the file written, and no question asked.

    ← Write agent-note.txt
    Wrote file successfully.
    
  4. Ask for a file outside the folder:

    opencode run "Create a file at /home/jovyan/outside-note.txt containing the single line: written by the agent. Use the write tool, not a shell command. Then stop."
    

    You should see: the request stopped. Run this way, nobody is there to answer, so OpenCode refuses for you.

    ! permission requested: external_directory (/home/jovyan/*); auto-rejecting
    ✗ Write /home/jovyan/outside-note.txt failed
    
  5. Ask the plan agent for a file here:

    opencode run --agent plan "Create a file named plan-note.txt in the current folder containing the single line: written by the agent. Then stop."
    

    You should see: a few lines describing how it would make the file, and no Write line.

  6. Look at what exists:

    ls ~/work/agent-test ~/outside-note.txt
    

    You should see: agent-note.txt alone in the folder, and No such file or directory for the other.

Check it worked

You can finish each sentence. "Inside the folder I start it in, the agent …" (writes without asking). "Outside that folder, it …" (must ask, and is refused when nobody answers). "To get advice and no changes, I …" (add --agent plan).

So choose the starting folder with care: start the agent in the smallest folder that holds the task, not in your home folder or your Data Store.

If it didn't

Step 3 or 5 gives an error about a key or a model. The key is not loaded in this terminal. Run the source line from step 3 of Sign in and start an AI agent in a MESA app and try again.

Step 5 wrote the file. Your rules differ from the ones seen here. Run opencode agent list, find plan, and look for a rule with permission edit.

Next

Not yet validated by a person in MESA JupyterLab. Drafted with AI assistance on 2026-11-20; every command was run there that day.

Machine-readable versions of this page: Markdown twin · raw source on GitHub · llms.txt · llms-full.txt (whole site). See For AI agents.