Agent ignores workspace restrictions and does whatever it wants

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

I’m posting this because I’m fed up.

I work in a firmware folder and I told the agent, clearly, to stay there. Do not leave that directory. I shouldn’t have to babysit it. If I wanted to do the job myself, I would.

It still went outside the workspace, up into the hardware/schematics, without permission. When I asked how it knew something it could only have learned from those files, it admitted it had no permission and did it anyway.

Then it got cocky about how it found it.

Even when the technical answer is right, that is not acceptable. A correct result does not give the agent a pass to ignore restrictions I set. “I’ll try not to next time” is useless. I cannot sit there watching every tool call.

I’m indignant. This keeps happening and I’m done with it. If I put a boundary on the workspace, the agent has to respect it. Full stop. Cursor needs to enforce that, not leave it to me to police a model that does whatever it wants.

Steps to Reproduce

  1. Open Cursor IDE with the workspace set to a nested folder (in my case firmware/SOUNDER-EXT). Parent folders contain other project files (hardware/schematics) that must stay out of scope.
  2. In Agent chat, tell the agent explicitly: stay inside this workspace folder; do not read, search, or leave that directory.
  3. Ask a question whose answer happens to exist in a parent folder (I asked why the board stays powered after unplug).
  4. The agent still searches/reads files outside the workspace (parent hardware schematics) without permission.
  5. When asked how it knew that, it admits it had no permission and did it anyway.

Expected Behavior

If I restrict the agent to the open workspace folder, it must not read, search, or traverse anything outside that folder. A clear instruction to stay inside the workspace must be enforced, not ignored when the answer looks easier to find elsewhere. The agent should refuse or say it cannot leave the workspace, instead of going into parent directories on its own.

Operating System

Linux

Version Information

Version: 3.27.22
VS Code Extension API: 1.128.0
Commit: b1aa50cb6db84fd3e8c808259cb172ea73425c10
Date: 2026-10-27T00:33:02.045Z
Layout: IDE
Build Type: Stable
Release Track: Default
Electron: 42.11.16
Chromium: 148.0.7778.280
Node.js: 24.19.0
V8: 14.8.178.38-electron.0
xterm.js: 6.1.0-beta.291
OS: Linux x64 7.0.0-42-generic

For AI issues: which model did you use?

Grok 4.6

For AI issues: add Request ID with privacy disabled

Privacy Mode stays on; I will not share a Request ID

Additional Information

This does not stop me from using Cursor today, but if workspace restrictions are not enforced I will have to look at other tools.

Does this stop you from using Cursor

No - Cursor works, but with this issue

You need to actually restrict access to the current workspace, not just “tell the agent to stay in it”. LLMs aren’t perfect yet, and if you tell the agent it only has access to one folder when in fact it has access to more (because you opened Cursor in a higher level folder, or it asked and you gave it permission to the other directory) then that is conflicting information just asking for inconsistent behavior.

So, open Cursor in the workspace you want it to access, and if it asks to access other folders, deny the request.

That is not what happened.

I opened Cursor in the firmware folder. That folder was the workspace. I did not open a parent directory, and I did not grant access to hardware/ or any other folder.

The agent still left the workspace, searched/read parent-folder schematics, and then admitted it had done so without permission.

“Open Cursor in the workspace you want” is already what I did. Telling me to deny a permission prompt does not apply: there was no prompt. The restriction was the workspace itself, and it was not enforced.

Hi @gschelotto, that matches what we’d expect with the default settings, and you’re right that a chat instruction isn’t enough. By default the agent’s Read Access is set to System, so it can read files outside the open folder without asking, which is why you never got a prompt. Opening Cursor on the firmware folder doesn’t limit reads on its own. There’s a setting that does:

  1. Open Cursor Settings → Agents → Execution and Approvals.
  2. Set Read Access to Workspace. Reading a file outside the folder then needs your approval, and searches leave out results from outside it.
  3. If your Run Mode list has a “(with Sandbox)” option, pick it (or use Ask Every Time), so terminal commands can’t read outside the workspace either. Read Access isn’t available in Run Everything mode.

Commands you’ve allowlisted run outside the sandbox, so keep that list narrow. If Read Access was already set to Workspace when this happened, let me know which Run Mode you were using.

Opening a subfolder doesn’t stop the agent from reading files outside it. Reading files doesn’t need approval, so you have to block it explicitly. What I’d do:

  1. Put a .cursorignore in the parent folder that lists hardware/ (or whatever’s off limits)
  2. Turn on Cursor Settings > Indexing > Ignore Files > Hierarchical Cursor Ignore so Cursor checks parent folders for that file
  3. In Settings > Agents > Approvals & Execution, use a stricter run mode than Run Everything, and add a block_instructions entry in .cursor/permissions.json like “any command that reads files outside this workspace needs approval first”

Caveat: the docs say the agent’s terminal and MCP tools can’t block access to ignored files, so a cat ../../hardware/... can still get through. Rules in a prompt aren’t enforcement either.

If you can turn on Share Data for a single repro and post the request ID, that’ll help the team see exactly which tool did the read.

more deets: Ignore File | Cursor Docs
approvals + permissions.json: Run Modes | Cursor Docs

Good lord why is that the default :joy: my apologies for jumping to conclusions @gschelotto . I think the default used to be workspace only, or at least that is how mine is set.

Thanks! — I’ll set Read Access to Workspace.

Thanks. I’ll skip .cursorignore / permissions.json for now — those aren’t a hard boundary, as you noted with the terminal caveat.

I’ve set Read Access to Workspace and a sandboxed run mode. That looks like the actual control. I’ll keep Privacy Mode on, so no Request ID.