Gemini CLI says "Tool execution denied by policy" for read, write, and shell tools - how to fix?
Gemini CLI 0.37.1 on Windows PowerShell, signed in with OAuth, denies every file read, write, and shell tool call with "Tool execution denied by policy", even after regenerating credentials and reinstalling. Users in the thread found local settings and policy rules that caused this.
Originally asked on GitHub: https://github.com/google-gemini/gemini-cli/issues/25283
5 answers
The issue was closed as NOT_PLANNED and later auto-closed as stale. The thread contains no maintainer fix, but it reports three local causes and workarounds.
One user had
security.enableConsecaenabled in~/.gemini/settings.json. Removing that setting fixed the denial for them. Another user, with Conseca disabled, had atools.allowedlist containing onlyrun_shell_command(ls). That caused otherrun_shell_commandcalls to be denied. Addingrun_shell_commandto aconfirmationRequiredlist made calls prompt instead. Run/policies listto see which rule denies a call and where it comes from.A third user found that default rules for
write_file,replace, andrun_shell_commandincluded both ASK_USER and DENY at the same priority (1.01), so edits were denied. Their workaround was adding ALLOW rules at priority 950 scoped to the project directory:toml[[rule]] decision = "allow" priority = 950 toolName = "write_file" argsPattern = '\0"file_path":"/path/to/project/.*"\0' modes = [ "default", "autoEdit", "yolo" ]Repeat the rule with
toolName = "replace". Keep the path pattern narrow so writes are not allowed outside your project.Security note: a broad allow rule for shell commands or writes lets the agent act without asking, so keep the scope as narrow as your workflow allows.
Did this work for you?What @r4m0np tried on GitHub (Didn't work)
Reporter revoked and regenerated application default credentials with gcloud and reinstalled Gemini CLI 0.37.1 on Windows, authenticated via OAuth. The denial persisted.
Source: https://github.com/google-gemini/gemini-cli/issues/25283 (opens external site)
Did this work for you?What @M4NZEN tried on GitHub (Worked)
Removed the Conseca setting (security.enableConseca) from ~/.gemini/settings.json. This fixed the denial for this commenter.
Did this work for you?What @foxwoodacademy tried on GitHub (Worked)
Added ALLOW rules at priority 950 in a policy TOML for write_file and replace, scoped with an argsPattern to the project directory, after finding tied ASK_USER and DENY default rules at priority 1.01. The commenter reported this worked on Android/Termux.
Did this work for you?What @jhutar tried on GitHub (Partly worked)
Added run_shell_command(ls) to tools.allowed in settings.json. Other run_shell_command calls were then denied. Adding run_shell_command to confirmationRequired made all calls, including ls, prompt for confirmation.
Did this work for you?
Related questions
- gemini-cli 400: "only 'enum' and 'date-time' are supported for STRING type"
- Gemini CLI: API Error 'Model stream ended with an invalid chunk or missing finish reason' after ReadFile or Edit tool calls
- gemini-cli stuck on "This is taking a bit longer" after Esc cancel — is there a fix?
- Is there a way to get codebase indexing in gemini-cli?
- How can I use voice input instead of typing with Gemini CLI?